1212class Config (object ):
1313 _instance = None # Global instance
1414
15+ # noinspection PyShadowingBuiltins
1516 def __init__ (
1617 self ,
1718 api_url = None ,
1819 api_key = None ,
1920 products = None ,
20- filename = None
21+ file = None
2122 ):
2223 """
2324 initialization config for public api
2425 :param api_url: Public api url
2526 :param api_key: Service user ApiKey
2627 :param products (optional): Id products
27- :param filename : Config file path
28+ :param file : Config file path
2829 """
2930 # Check arguments
30- if not filename and not any ([api_key , api_url ]):
31+ if not file and not any ([api_key , api_url ]):
3132 raise ValueError ('Filename or api_key and api_url are expected'
3233 'in Config initialization' )
3334 if products and not isinstance (products , (str , list )):
3435 raise TypeError ('Products can be string or string list. Found type '
3536 + type (products ).__name__ )
3637
3738 # Load config from file name
38- if filename :
39- if not os .path .exists (filename ):
40- raise IOError ('No filename `{}` on directory' .format (filename ))
39+ if file :
40+ if not os .path .exists (file ):
41+ raise IOError ('No file `{}` on directory' .format (file ))
4142
42- with open (filename ) as config_file :
43+ with open (file ) as config_file :
4344 configs = config_file .read ()
4445
4546 try :
4647 configs = json .loads (configs )
4748 except Exception as ex :
48- raise TypeError ('Invalid config filename `{}`\n '
49- 'ERROR: {}' .format (filename , str (ex )))
49+ raise TypeError ('Invalid config file `{}`\n '
50+ 'ERROR: {}' .format (file , str (ex )))
5051
5152 (api_url , api_key , products ) = (configs .get ('apiEndpoint' , '' ),
5253 configs .get ('apiKey' , '' ),
@@ -71,7 +72,7 @@ def __init__(
7172 @classmethod
7273 def get_instance (cls ):
7374 if not cls ._instance :
74- cls ._instance = Config (filename = 'config.json' )
75+ cls ._instance = Config (file = 'config.json' )
7576 return cls ._instance
7677
7778 @property
0 commit comments