def cache( self ): for key, data in self.refs.items(): if key not in self.items: instance = data['instance'] block_klass = data['block_klass'] block_kwargs = data['block_kwargs'] offset = property_get( data['offset'], instance ) size = property_get( data['size'], instance ) transform = data['transform'] buffer = self.source[self.base_offset+offset:][:size] if transform: buffer = transform.import_data( buffer, parent=instance ).payload self.items[key] = block_klass( source_data=buffer, parent=instance, **block_kwargs )
def cache(self): for key, data in self.refs.items(): if key not in self.items: instance = data['instance'] block_klass = data['block_klass'] block_kwargs = data['block_kwargs'] offset = property_get(data['offset'], instance) size = property_get(data['size'], instance) transform = data['transform'] buffer = self.source[self.base_offset + offset:][:size] if transform: buffer = transform.import_data(buffer, parent=instance).payload self.items[key] = block_klass(source_data=buffer, parent=instance, **block_kwargs)
def check_buffer(self, buffer, parent=None): test = self.field.get_from_buffer(buffer, parent) value = property_get(self.target, parent) if test != value: mismatch = f'{self}:{value}, found {test}!' if self.raise_exception: raise CheckException(mismatch) logger.warning(mismatch)
def update_buffer(self, buffer, parent=None): value = property_get(self.source, parent) self.property_set(self.target, parent, value)
def remove(self, instance): store = property_get(self.store, instance) return store.remove_object(instance, self.offset, self.size)
def set(self, instance, value): store = property_get(self.store, instance) assert isinstance(value, self.block_klass) return store.set_object(instance, self.offset, self.size, value)
def get(self, instance): store = property_get(self.store, instance) return store.get_object(instance, self.offset, self.size)
def cache(self, instance): store = property_get(self.store, instance) store.cache_object(instance, self.offset, self.size, self.block_klass, self.block_kwargs, self.transform)
def get_size(self, parent=None): value = property_get(self.target, parent) return self.field.get_size(value, parent)
def update_deps(self, parent=None): if parent: name = parent.get_field_name_by_obj(self.field) value = property_get(self.target, parent) property_set(Ref(name), parent, value) return
def remove( self, instance ): store = property_get( self.store, instance ) return store.remove_object( instance, self.offset, self.size )
def set( self, instance, value ): store = property_get( self.store, instance ) assert isinstance( value, self.block_klass ) return store.set_object( instance, self.offset, self.size, value )
def get( self, instance ): store = property_get( self.store, instance ) return store.get_object( instance, self.offset, self.size )
def cache( self, instance ): store = property_get( self.store, instance ) store.cache_object( instance, self.offset, self.size, self.block_klass, self.block_kwargs, self.transform )