<s> import logging <EOL> import stat as stat_module <EOL> logger = logging . getLogger ( __name__ ) <EOL> def do_overwrite_save ( fs , path , data ) : <EOL> def copy_data ( path_dest ) : <EOL> try : <EOL> fs . create ( path_dest , overwrite = False , data = data ) <EOL> logging . info ( "<STR_LIT>" + path_dest ) <EOL> except Exception , e : <EOL> try : <EOL> fs . remove ( path_dest , skip_trash = True ) <EOL> except : <EOL> logger . exception ( '<STR_LIT>' % path_dest ) <EOL> raise e <EOL> _do_overwrite ( fs , path , copy_data ) <EOL> def remove_header ( fs , path ) : <EOL> def copy_data ( path_dest ) : <EOL> fs . copyfile ( path , path_dest , skip_header = True ) <EOL> _do_overwrite ( fs , path , copy_data ) <EOL> def _do_overwrite ( fs , path , copy_data ) : <EOL> """<STR_LIT>""" <EOL> path_dest = path + "<STR_LIT>" <EOL> copy_data ( path_dest ) <EOL> cur_stats = fs . stats ( path ) <EOL> try : <EOL> fs . do_as_superuser ( fs . chmod , path_dest , stat_module . S_IMODE ( cur_stats [ '<STR_LIT>' ] ) ) <EOL> except : <EOL> logging . exception ( "<STR_LIT>" % ( path_dest , path ) ) <EOL> try : <EOL> fs . do_as_superuser ( fs . chown , path_dest , cur_stats [ '<STR_LIT:user>' ] , cur_stats [ '<STR_LIT>' ] ) <EOL> except : <EOL> logging . exception ( "<STR_LIT>" % ( path_dest , path ) ) <EOL> fs . remove ( path , skip_trash = True ) <EOL> fs . rename ( path_dest , path ) </s>
