def _do_overwrite(fs, path, copy_data):
 path_dest = (path + '._hue_new')
 copy_data(path_dest)
 cur_stats = fs.stats(path)
 try:
  fs.do_as_superuser(fs.chmod, path_dest, stat_module.S_IMODE(cur_stats['mode']))
 except:
  logging.exception(('Could not chmod new file %s to match old file %s' % (path_dest, path)))
 try:
  fs.do_as_superuser(fs.chown, path_dest, cur_stats['user'], cur_stats['group'])
 except:
  logging.exception(('Could not chown new file %s to match old file %s' % (path_dest, path)))
 fs.remove(path, skip_trash=True)
 fs.rename(path_dest, path)

def _do_overwrite ( fs , path , copy_data ) : path_dest = ( path + '._hue_new' ) copy_data ( path_dest ) cur_stats = fs . stats ( path ) try : fs . do_as_superuser ( fs . chmod , path_dest , stat_module . S_IMODE ( cur_stats [ 'mode' ] ) ) except : logging . exception ( ( 'Could not chmod new file %s to match old file %s' % ( path_dest , path ) ) ) try : fs . do_as_superuser ( fs . chown , path_dest , cur_stats [ 'user' ] , cur_stats [ 'group' ] ) except : logging . exception ( ( 'Could not chown new file %s to match old file %s' % ( path_dest , path ) ) ) fs . remove ( path , skip_trash = True ) fs . rename ( path_dest , path )
atomically save the specified data to the given path on the filesystem .