toolsutils.py
changeset 10614 57dfde80df11
parent 10591 8e46ed1a0b8a
child 10688 fa29f3628a1b
equal deleted inserted replaced
10613:8d9fe02387e3 10614:57dfde80df11
   110             print('replaced')
   110             print('replaced')
   111         elif action == 'q':
   111         elif action == 'q':
   112             sys.exit(0)
   112             sys.exit(0)
   113         else:
   113         else:
   114             copy_file = appl_file + '.default'
   114             copy_file = appl_file + '.default'
   115             copy = file(copy_file, 'w')
   115             copy = open(copy_file, 'w')
   116             copy.write(open(ref_file).read())
   116             copy.write(open(ref_file).read())
   117             copy.close()
   117             copy.close()
   118             print('keep current version, the new file has been written to', copy_file)
   118             print('keep current version, the new file has been written to', copy_file)
   119     else:
   119     else:
   120         print('no diff between %s and %s' % (appl_file, ref_file))
   120         print('no diff between %s and %s' % (appl_file, ref_file))
   149                 show_diffs(tfpath, fpath, askconfirm)
   149                 show_diffs(tfpath, fpath, askconfirm)
   150             else:
   150             else:
   151                 shutil.copyfile(fpath, tfpath)
   151                 shutil.copyfile(fpath, tfpath)
   152 
   152 
   153 def fill_templated_file(fpath, tfpath, context):
   153 def fill_templated_file(fpath, tfpath, context):
   154     fobj = file(tfpath, 'w')
   154     fobj = open(tfpath, 'w')
   155     templated = file(fpath).read()
   155     templated = open(fpath).read()
   156     fobj.write(templated % context)
   156     fobj.write(templated % context)
   157     fobj.close()
   157     fobj.close()
   158 
   158 
   159 def restrict_perms_to_user(filepath, log=None):
   159 def restrict_perms_to_user(filepath, log=None):
   160     """set -rw------- permission on the given file"""
   160     """set -rw------- permission on the given file"""