modules.py 文件源码

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

项目:openshift-restclient-python 作者: openshift 项目源码 文件源码
def __jinja_render_to_file(cls, template_path, template_file, module_name,
                               temp_dir, module_path, **context):
        """
        Create the module from a jinja template.

        :param template_file: name of the template file
        :param module_name: the destination file name
        :param temp_dir: a temporary working dir for jinja
        :param context: dict of substitution variables
        :return: None
        """
        j2_tmpl_path = template_path
        j2_env = Environment(loader=FileSystemLoader(j2_tmpl_path), keep_trailing_newline=True)
        j2_tmpl = j2_env.get_template(template_file)
        rendered = j2_tmpl.render(dict(temp_dir=temp_dir, **context))
        with open(os.path.normpath(os.path.join(module_path, module_name)), 'wb') as f:
            f.write(rendered.encode('utf8'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号