@@ -19,27 +19,24 @@ def __init__(self, path, env_var, default_filename):
1919 self .default_file = default_filename
2020
2121 def get_file (self , fn = None ):
22- return self ._get_conf_from_file (fn ) or self ._get_conf_from_env ( fn )
22+ return self ._get_conf_from_env (fn ) or self ._get_conf_from_file ( self . path , fn )
2323
2424 def put_file (self , content , mode = "w" ):
25- self .get_or_setpath ()
26- file_to_write = open (self . path , mode )
25+ path = self .get_path_from_env ()
26+ file_to_write = open (path , mode )
2727 file_to_write .write (content ) # The key is type bytes still
2828 file_to_write .close ()
2929
30- def get_or_setpath (self ):
30+ def get_path_from_env (self ):
3131 config_file = os .environ .get (self .file_env_location , self .default_file )
3232 logger .debug ("Searching file in ENV[{}]: {}..." .format (self .file_env_location , config_file ))
33- self .path = config_file
34- return self .path
33+ return config_file
3534
3635 def _get_conf_from_env (self , fn = None ):
37- self .get_or_setpath ()
38- return self ._get_conf_from_file (fn )
39-
40- def _get_conf_from_file (self , fn = None ):
41- path = self .path
36+ path = self .get_path_from_env ()
37+ return self ._get_conf_from_file (path , fn )
4238
39+ def _get_conf_from_file (self , path , fn = None ):
4340 if path and os .path .isdir (path ):
4441 path = os .path .join (path , self .default_file )
4542
@@ -48,6 +45,7 @@ def _get_conf_from_file(self, fn=None):
4845 return {}
4946 if path not in files_cached :
5047 logger .debug ("[CONF] Configmap {} found" .format (path ))
48+ self .path = path
5149 if fn :
5250 files_cached [path ] = fn (path )
5351 else :
0 commit comments