core.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:gitlabform 作者: egnyte 项目源码 文件源码
def __init__(self, config_path=None):
        try:
            # using this env var should be considered unofficial, we need this temporarily for backwards compatibility.
            # support for it may be removed without notice, do not use it!
            if 'APP_HOME' in os.environ:
                config_path = os.path.join(os.environ['APP_HOME'], 'config.yml')
            # this case is only meant for using gitlabform as a library
            elif not config_path:
                config_path = os.path.join(str(Path.home()), '.gitlabform', 'config.yml')
            elif config_path in [os.path.join('.', 'config.yml'), 'config.yml']:
                config_path = os.path.join(os.getcwd(), 'config.yml')

            logging.info("Reading config from: {}".format(config_path))

            with open(config_path, 'r') as ymlfile:
                self.config_from_file = yaml.safe_load(ymlfile)

            # we need config path for accessing files for relative paths
            self.config_dir = os.path.dirname(config_path)

        except Exception as e:
            raise ConfigFileNotFoundException(config_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号