LegenJCdary / ingeSTation

Python application designed for data ingest(at)ion and controlling operations on ingest stations. ST stands for Speedy Transfer or Super Turbo.
MIT License
1 stars 0 forks source link

conf_path handling #12

Open LegenJCdary opened 11 months ago

LegenJCdary commented 11 months ago

User should be allowed to provide operator (and perhaps project) configuration file as cli arguments. This should (probably) never be allowed for application conf.

LegenJCdary commented 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 ""