(profile_name=None, _reset_sessions=True, _update_metadata=True, _create_new=True, _metadata_only=False)
return upgrade_version(loaded_data, reset_sessions=_reset_sessions, update_metadata=_update_metadata)
Read a profile (or create new one) and run it through the update.
    Use LoadData class instead of this.
Read a profile (or create new one) and run it through the update.
    Use LoadData class instead of this.
Read a profile ( or create new one ) and run it through the update . Use LoadData class instead of this .
def load_data(profile_name=None, _reset_sessions=True, _update_metadata=True, _create_new=True, _metadata_only=False):
    """Read a profile (or create new one) and run it through the update.
    Use LoadData class instead of this.
    """
    paths = _get_paths(profile_name)
    new_file = False
    
    if _metadata_only:
        with CustomOpen(paths['Main'], 'rb') as f:
            metadata = {}

            #Read metadata from zip file
            if f.zip is not None:
                metadata_files = [path for path in f.zip.namelist() if path.startswith('metadata/')]
                for path in metadata_files:
                    metadata[path[9:-4]] = f.read(path)

            #Use inbuilt OS way to get modified time if no metadata
            if 'modified' not in metadata:
                metadata['modified'] = get_modified_time(paths['Main'])
            
            #Get misc information
            metadata['filesize'] = get_file_size(paths['Main'])

            return metadata

    #Load the main file
    try:
        with CustomOpen(paths['Main'], 'rb') as f:
            loaded_data = decode_file(f, legacy=f.zip is None, lazy_load_path=paths['Main'])
            
    #Load backup if file is corrupted
    except (zlib.error, ValueError, zipfile.BadZipfile):
        try:
            with CustomOpen(paths['Backup'], 'rb') as f:
                loaded_data = decode_file(f, legacy=f.zip is None, lazy_load_path=paths['Main'])
                
        except (IOError, zlib.error, ValueError):
            new_file = True
            
            #Move corrupt file into a folder instead of just silently delete
            if create_folder(paths['CorruptedFolder'], is_file=False):
                hide_file(paths['CorruptedFolder'])
            rename_file(paths['Main'], '{}.{}'.format(paths['Corrupted'], int(time.time())))
    
    #Don't load backup if file has been deleted
    except IOError:
        new_file = True
    
    #Create empty data
    if new_file:
        if _create_new:
            loaded_data = {}
        else:
            return None
    
    return upgrade_version(loaded_data, reset_sessions=_reset_sessions, update_metadata=_update_metadata)
def load_data ( profile_name = None , _reset_sessions = True , _update_metadata = True , _create_new = True , _metadata_only = False ) : paths = _get_paths ( profile_name ) new_file = False if _metadata_only : with CustomOpen ( paths [ 'Main' ] , 'rb' ) as f : metadata = { } #Read metadata from zip file if f . zip is not None : metadata_files = [ path for path in f . zip . namelist ( ) if path . startswith ( 'metadata/' ) ] for path in metadata_files : metadata [ path [ 9 : - 4 ] ] = f . read ( path ) #Use inbuilt OS way to get modified time if no metadata if 'modified' not in metadata : metadata [ 'modified' ] = get_modified_time ( paths [ 'Main' ] ) #Get misc information metadata [ 'filesize' ] = get_file_size ( paths [ 'Main' ] ) return metadata #Load the main file try : with CustomOpen ( paths [ 'Main' ] , 'rb' ) as f : loaded_data = decode_file ( f , legacy = f . zip is None , lazy_load_path = paths [ 'Main' ] ) #Load backup if file is corrupted except ( zlib . error , ValueError , zipfile . BadZipfile ) : try : with CustomOpen ( paths [ 'Backup' ] , 'rb' ) as f : loaded_data = decode_file ( f , legacy = f . zip is None , lazy_load_path = paths [ 'Main' ] ) except ( IOError , zlib . error , ValueError ) : new_file = True #Move corrupt file into a folder instead of just silently delete if create_folder ( paths [ 'CorruptedFolder' ] , is_file = False ) : hide_file ( paths [ 'CorruptedFolder' ] ) rename_file ( paths [ 'Main' ] , '{}.{}' . format ( paths [ 'Corrupted' ] , int ( time . time ( ) ) ) ) #Don't load backup if file has been deleted except IOError : new_file = True #Create empty data if new_file : if _create_new : loaded_data = { } else : return None return upgrade_version ( loaded_data , reset_sessions = _reset_sessions , update_metadata = _update_metadata )