pypet/storageservice.py
def _prm_store_from_dict(self, fullname, store_dict, hdf5_group, store_flags, kwargs):
        """Stores a `store_dict`"""
        for key, data_to_store in store_dict.items():
            # self._logger.log(1, 'SUB-Storing %s [%s]', key, str(store_dict[key]))
            original_hdf5_group = None

            flag = store_flags[key]

            if '.' in key:
                original_hdf5_group = hdf5_group
                split_key = key.split('.')
                key = split_key.pop()
                for inner_key in split_key:
                    hdf5_group, newly_created =  self._all_create_or_get_group(inner_key,
                                                                                hdf5_group)
                    if newly_created:
                        setattr(hdf5_group._v_attrs, HDF5StorageService.STORAGE_TYPE,
                                HDF5StorageService.NESTED_GROUP)
                    else:
                        store_type = self._all_get_from_attrs(hdf5_group, HDF5StorageService.STORAGE_TYPE)
                        if store_type != HDF5StorageService.NESTED_GROUP:
                            raise ValueError('You want to nested results but `%s` is already '
                                             'of type `%s`!' % (hdf5_group._v_name, store_type))

            # Iterate through the data and store according to the storage flags
            if key in hdf5_group:
                # We won't change any data that is found on disk
                self._logger.debug(
                    'Found %s already in hdf5 node of %s, so I will ignore it.' %
                    (key, fullname))
                continue

            if flag == HDF5StorageService.TABLE:
                # self._logger.log(1, 'SUB-Storing %s TABLE', key)
                self._prm_write_into_pytable(key, data_to_store, hdf5_group, fullname,
                                             **kwargs)
            elif flag == HDF5StorageService.DICT:
                # self._logger.log(1, 'SUB-Storing %s DICT', key)
                self._prm_write_dict_as_table(key, data_to_store, hdf5_group, fullname,
                                              **kwargs)
            elif flag == HDF5StorageService.ARRAY:
                # self._logger.log(1, 'SUB-Storing %s ARRAY', key)
                self._prm_write_into_array(key, data_to_store, hdf5_group, fullname,
                                           **kwargs)
            elif flag in (HDF5StorageService.CARRAY,
                          HDF5StorageService.EARRAY,
                          HDF5StorageService.VLARRAY):
                self._prm_write_into_other_array(key, data_to_store,
                                                 hdf5_group, fullname,
                                                 flag=flag, **kwargs)
            elif flag in (HDF5StorageService.SERIES,
                          HDF5StorageService.FRAME,
                          #  HDF5StorageService.PANEL
                          ):
                # self._logger.log(1, 'SUB-Storing %s PANDAS', key)
                self._prm_write_pandas_data(key, data_to_store, hdf5_group, fullname,
                                            flag, **kwargs)
            elif flag == HDF5StorageService.SHARED_DATA:
                pass  # Shared data needs to be explicitly created and is not stored on
                # the fly
            else:
                raise RuntimeError('You shall not pass!')

            if original_hdf5_group is not None:
                hdf5_group = original_hdf5_group
def _prm_store_from_dict(self, fullname, store_dict, hdf5_group, store_flags, kwargs):
        for key, data_to_store in store_dict.items():
            # self._logger.log(1, 'SUB-Storing %s [%s]', key, str(store_dict[key]))
            original_hdf5_group = None

            flag = store_flags[key]

            if '.' in key:
                original_hdf5_group = hdf5_group
                split_key = key.split('.')
                key = split_key.pop()
                for inner_key in split_key:
                    hdf5_group, newly_created =  self._all_create_or_get_group(inner_key,
                                                                                hdf5_group)
                    if newly_created:
                        setattr(hdf5_group._v_attrs, HDF5StorageService.STORAGE_TYPE,
                                HDF5StorageService.NESTED_GROUP)
                    else:
                        store_type = self._all_get_from_attrs(hdf5_group, HDF5StorageService.STORAGE_TYPE)
                        if store_type != HDF5StorageService.NESTED_GROUP:
                            raise ValueError('You want to nested results but `%s` is already '
                                             'of type `%s`!' % (hdf5_group._v_name, store_type))

            # Iterate through the data and store according to the storage flags
            if key in hdf5_group:
                # We won't change any data that is found on disk
                self._logger.debug(
                    'Found %s already in hdf5 node of %s, so I will ignore it.' %
                    (key, fullname))
                continue

            if flag == HDF5StorageService.TABLE:
                # self._logger.log(1, 'SUB-Storing %s TABLE', key)
                self._prm_write_into_pytable(key, data_to_store, hdf5_group, fullname,
                                             **kwargs)
            elif flag == HDF5StorageService.DICT:
                # self._logger.log(1, 'SUB-Storing %s DICT', key)
                self._prm_write_dict_as_table(key, data_to_store, hdf5_group, fullname,
                                              **kwargs)
            elif flag == HDF5StorageService.ARRAY:
                # self._logger.log(1, 'SUB-Storing %s ARRAY', key)
                self._prm_write_into_array(key, data_to_store, hdf5_group, fullname,
                                           **kwargs)
            elif flag in (HDF5StorageService.CARRAY,
                          HDF5StorageService.EARRAY,
                          HDF5StorageService.VLARRAY):
                self._prm_write_into_other_array(key, data_to_store,
                                                 hdf5_group, fullname,
                                                 flag=flag, **kwargs)
            elif flag in (HDF5StorageService.SERIES,
                          HDF5StorageService.FRAME,
                          #  HDF5StorageService.PANEL
                          ):
                # self._logger.log(1, 'SUB-Storing %s PANDAS', key)
                self._prm_write_pandas_data(key, data_to_store, hdf5_group, fullname,
                                            flag, **kwargs)
            elif flag == HDF5StorageService.SHARED_DATA:
                pass  # Shared data needs to be explicitly created and is not stored on
                # the fly
            else:
                raise RuntimeError('You shall not pass!')

            if original_hdf5_group is not None:
                hdf5_group = original_hdf5_group
def _prm_store_from_dict ( self , fullname , store_dict , hdf5_group , store_flags , kwargs ) : for key , data_to_store in store_dict . items ( ) : # self._logger.log(1, 'SUB-Storing %s [%s]', key, str(store_dict[key])) original_hdf5_group = None flag = store_flags [ key ] if '.' in key : original_hdf5_group = hdf5_group split_key = key . split ( '.' ) key = split_key . pop ( ) for inner_key in split_key : hdf5_group , newly_created = self . _all_create_or_get_group ( inner_key , hdf5_group ) if newly_created : setattr ( hdf5_group . _v_attrs , HDF5StorageService . STORAGE_TYPE , HDF5StorageService . NESTED_GROUP ) else : store_type = self . _all_get_from_attrs ( hdf5_group , HDF5StorageService . STORAGE_TYPE ) if store_type != HDF5StorageService . NESTED_GROUP : raise ValueError ( 'You want to nested results but `%s` is already ' 'of type `%s`!' % ( hdf5_group . _v_name , store_type ) ) # Iterate through the data and store according to the storage flags if key in hdf5_group : # We won't change any data that is found on disk self . _logger . debug ( 'Found %s already in hdf5 node of %s, so I will ignore it.' % ( key , fullname ) ) continue if flag == HDF5StorageService . TABLE : # self._logger.log(1, 'SUB-Storing %s TABLE', key) self . _prm_write_into_pytable ( key , data_to_store , hdf5_group , fullname , * * kwargs ) elif flag == HDF5StorageService . DICT : # self._logger.log(1, 'SUB-Storing %s DICT', key) self . _prm_write_dict_as_table ( key , data_to_store , hdf5_group , fullname , * * kwargs ) elif flag == HDF5StorageService . ARRAY : # self._logger.log(1, 'SUB-Storing %s ARRAY', key) self . _prm_write_into_array ( key , data_to_store , hdf5_group , fullname , * * kwargs ) elif flag in ( HDF5StorageService . CARRAY , HDF5StorageService . EARRAY , HDF5StorageService . VLARRAY ) : self . _prm_write_into_other_array ( key , data_to_store , hdf5_group , fullname , flag = flag , * * kwargs ) elif flag in ( HDF5StorageService . SERIES , HDF5StorageService . FRAME , #  HDF5StorageService.PANEL ) : # self._logger.log(1, 'SUB-Storing %s PANDAS', key) self . _prm_write_pandas_data ( key , data_to_store , hdf5_group , fullname , flag , * * kwargs ) elif flag == HDF5StorageService . SHARED_DATA : pass # Shared data needs to be explicitly created and is not stored on # the fly else : raise RuntimeError ( 'You shall not pass!' ) if original_hdf5_group is not None : hdf5_group = original_hdf5_group
Stores a `store_dict`
Stores a store_dict