Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit695cc55

Browse files
committed
Simplified initialization
1 parenta3e2902 commit695cc55

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎etherscan/etherscan.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
importjson
2+
fromimportlibimportresources
23

34
importrequests
45

56
importetherscan
7+
frometherscanimportconfigs
68
frometherscan.enums.fields_enumimportFieldsEnumasfields
79
frometherscan.utils.parsingimportResponseParserasparser
810

911

1012
classEtherscan:
13+
def__new__(cls,api_key:str):
14+
withresources.path(configs,"stable.json")aspath:
15+
config_path=str(path)
16+
returncls.from_config(api_key=api_key,config_path=config_path)
17+
1118
@staticmethod
1219
def__load_config(config_path:str)->dict:
1320
withopen(config_path,"r")asf:
1421
returnjson.load(f)
1522

1623
@staticmethod
17-
def__run(func,api_key):
24+
def__run(func,api_key:str):
1825
defwrapper(*args,**kwargs):
1926
url= (
2027
f"{fields.PREFIX}"
@@ -28,7 +35,7 @@ def wrapper(*args, **kwargs):
2835
returnwrapper
2936

3037
@classmethod
31-
deffrom_config(cls,config_path:str,api_key:str):
38+
deffrom_config(cls,api_key:str,config_path:str):
3239
config=cls.__load_config(config_path)
3340
forfunc,vinconfig.items():
3441
ifnotfunc.startswith("_"):# disabled if _

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp