import os
import pwd
+from string import Template
def fix_user_dirs(path, user=None, mode=0700):
if pw:
os.chown(root, pw.pw_uid, pw.pw_gid)
os.chmod(root, mode)
+
+
+def write_from_template(destfile, template, opts):
+ with open(template) as f:
+ t = Template(f.read())
+ text = t.substitute(**opts) # pylint: disable=star-args
+ with open(destfile, 'w+') as f:
+ f.write(text)