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.
评论列表
文章目录