rfho/save_and_load.py
def pack_save_dictionaries(self, name='all', append_string='', erase_others=True):
        """
        Creates an unique file starting from file created by method `save`.
        The file contains a dictionary with keys equal to save_dict keys and values list of values form original files.

        :param name:
        :param append_string:
        :param erase_others:
        :return: The generated dictionary
        """
        import glob
        all_files = sorted(glob.glob(join_paths(
            self.directory, FOLDER_NAMINGS['OBJ_DIR'], '[0-9]*%s.pkgz' % append_string)),
            key=os.path.getctime)  # sort by creation time
        if len(all_files) == 0:
            print('No file found')
            return

        objs = [load_obj(path, root_dir='', notebook_mode=False) for path in all_files]

        # packed_dict = OrderedDict([(k, []) for k in objs[0]])

        # noinspection PyArgumentList
        packed_dict = defaultdict(list, OrderedDict())
        for obj in objs:
            [packed_dict[k].append(v) for k, v in obj.items()]
        self.save_obj(packed_dict, name=name + append_string)

        if erase_others:
            [os.remove(f) for f in all_files]

        return packed_dict

        Creates an unique file starting from file created by method `save`.
        The file contains a dictionary with keys equal to save_dict keys and values list of values form original files.

        :param name:
        :param append_string:
        :param erase_others:
        :return: The generated dictionary
        
Creates an unique file starting from file created by method `save`.
The file contains a dictionary with keys equal to save_dict keys and values list of values form original files.
Creates an unique file starting from file created by method ` save ` . The file contains a dictionary with keys equal to save_dict keys and values list of values form original files .
def pack_save_dictionaries(self, name='all', append_string='', erase_others=True):
        import glob
        all_files = sorted(glob.glob(join_paths(
            self.directory, FOLDER_NAMINGS['OBJ_DIR'], '[0-9]*%s.pkgz' % append_string)),
            key=os.path.getctime)  
        if len(all_files) == 0:
            print('No file found')
            return
        objs = [load_obj(path, root_dir='', notebook_mode=False) for path in all_files]
        packed_dict = defaultdict(list, OrderedDict())
        for obj in objs:
            [packed_dict[k].append(v) for k, v in obj.items()]
        self.save_obj(packed_dict, name=name + append_string)
        if erase_others:
            [os.remove(f) for f in all_files]
        return packed_dict
def pack_save_dictionaries ( self , name = 'all' , append_string = '' , erase_others = True ) : import glob all_files = sorted ( glob . glob ( join_paths ( self . directory , FOLDER_NAMINGS [ 'OBJ_DIR' ] , '[0-9]*%s.pkgz' % append_string ) ) , key = os . path . getctime ) if len ( all_files ) == 0 : print ( 'No file found' ) return objs = [ load_obj ( path , root_dir = '' , notebook_mode = False ) for path in all_files ] packed_dict = defaultdict ( list , OrderedDict ( ) ) for obj in objs : [ packed_dict [ k ] . append ( v ) for k , v in obj . items ( ) ] self . save_obj ( packed_dict , name = name + append_string ) if erase_others : [ os . remove ( f ) for f in all_files ] return packed_dict
Creates an unique file starting from file created by method `save`.
Creates an unique file starting from file created by method ` save ` .
"""
        Creates an unique file starting from file created by method `save`.
        The file contains a dictionary with keys equal to save_dict keys and values list of values form original files.

        :param name:
        :param append_string:
        :param erase_others:
        :return: The generated dictionary
        """ # sort by creation time # packed_dict = OrderedDict([(k, []) for k in objs[0]]) # noinspection PyArgumentList
The generated dictionary
The generated dictionary
self
name
None
append_string
None
erase_others
None