config_reader.py 文件源码

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

项目:sceptre 作者: cloudreach 项目源码 文件源码
def _read(self, directory_path, basename):
        """
        Traverses the directory_path, from top to bottom, reading in all
        relevant config files. If config items appear in files lower down the
        environment tree, they overwrite items from further up.

        :param directory_path: Relative directory path to config to read.
        :type directory_path: str
        :param filename: Base config to provide defaults.
        :type filename: dict
        :returns: Representation of inherited config.
        :rtype: dict
        """
        abs_directory_path = path.join(self.config_folder, directory_path)
        if path.isfile(path.join(abs_directory_path, basename)):
            env = jinja2.Environment(
                loader=jinja2.FileSystemLoader(abs_directory_path),
                undefined=jinja2.StrictUndefined
            )
            template = env.get_template(basename)
            rendered_template = template.render(
                environment_variable=environ,
                environment_path=directory_path.split("/"),
                **self.templating_vars
            )
            config = yaml.safe_load(rendered_template)
            return config
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号