zenias_functions.py 文件源码

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

项目:zenias-python 作者: DevBlend 项目源码 文件源码
def z_make_templates(source, target, replacements):
    for f in os.listdir(source):
        newtarget = os.path.join(target, f)
        newsource = os.path.join(source, f)
        if os.path.isdir(newsource):
            os.makedirs(newtarget)
            print z_info('Created folder ' + f)
            z_make_templates(newsource, newtarget, replacements)
        else:
            targetfile = io.open(newtarget, 'w')
            sourcefile = io.open(newsource, 'r')
            for line in sourcefile:
                template = Template(line)
                targetfile.write(template.substitute(replacements))
            targetfile.close()
            print z_info('Created file ' + f)


# Merge two dicts recursively.
# Values from y will override the ones from x
# Returns x or y if the other is empty.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号