common.py 文件源码

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

项目:cloud-custodian 作者: capitalone 项目源码 文件源码
def write_policy_file(self, policy, format='yaml'):
        """ Write a policy file to disk in the specified format.

        Input a dictionary and a format. Valid formats are `yaml` and `json`
        Returns the file path.
        """
        fh = tempfile.NamedTemporaryFile(mode='w+b', suffix='.' + format)
        if format == 'json':
            fh.write(json.dumps(policy).encode('utf8'))
        else:
            fh.write(yaml.dump(policy, encoding='utf8', Dumper=yaml.SafeDumper))

        fh.flush()
        self.addCleanup(fh.close)
        return fh.name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号