Open LegenJCdary opened 11 months ago
"Backup" solution for obtaining conf paths.
def get_conf_path(self, conf_path: Union[bool, str]) -> str:
if not conf_path:
conf_path = self.get_conf_here()
if os.path.isfile(conf_path):
return conf_path
conf_path = os.path.join(global_vars.APPLICATION_DIR, f"{self.conf_type}.json")
if os.path.isfile(conf_path):
return conf_path
raise FileNotFoundError(f"[CRITICAL]: {self.conf_type.capitalize()}"
" configuration could not be obtained.")
return conf_path
def get_conf_here(self) -> str:
for file in os.listdir(os.getcwd()):
if file.endswith(f"{self.conf_type}.json"):
return os.path.join(os.getcwd(), file)
return ""
User should be allowed to provide operator (and perhaps project) configuration file as cli arguments. This should (probably) never be allowed for application conf.