(profile_name, data, _compress=True)
Handle the safe saving of profiles.
    
    Instead of overwriting, it will save as a temprary file and attempt to rename.
    At any point in time there are two copies of the save.
Handle the safe saving of profiles.
    
    Instead of overwriting, it will save as a temprary file and attempt to rename.
    At any point in time there are two copies of the save.
Handle the safe saving of profiles . Instead of overwriting it will save as a temprary file and attempt to rename . At any point in time there are two copies of the save .
def save_data(profile_name, data, _compress=True):
    """Handle the safe saving of profiles.
    
    Instead of overwriting, it will save as a temprary file and attempt to rename.
    At any point in time there are two copies of the save.
    """
    #This is to allow pre-compressed data to be sent in
    if _compress:
        data = prepare_file(data)
    
    paths = _get_paths(profile_name)
    
    if create_folder(paths['BackupFolder'], is_file=False):
        hide_file(paths['BackupFolder'])
    if create_folder(paths['TempFolder'], is_file=False):
        hide_file(paths['TempFolder'])
    with open(paths['Temp'], 'wb') as f:
        f.write(data)
    remove_file(paths['Backup'])
    rename_file(paths['Main'], paths['Backup'])
    if rename_file(paths['Temp'], paths['Main']):
        return True
    else:
        remove_file(paths['Temp'])
        return False
def save_data ( profile_name , data , _compress = True ) : #This is to allow pre-compressed data to be sent in if _compress : data = prepare_file ( data ) paths = _get_paths ( profile_name ) if create_folder ( paths [ 'BackupFolder' ] , is_file = False ) : hide_file ( paths [ 'BackupFolder' ] ) if create_folder ( paths [ 'TempFolder' ] , is_file = False ) : hide_file ( paths [ 'TempFolder' ] ) with open ( paths [ 'Temp' ] , 'wb' ) as f : f . write ( data ) remove_file ( paths [ 'Backup' ] ) rename_file ( paths [ 'Main' ] , paths [ 'Backup' ] ) if rename_file ( paths [ 'Temp' ] , paths [ 'Main' ] ) : return True else : remove_file ( paths [ 'Temp' ] ) return False