Example #1
0
    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 )
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 def update_buffer(self, buffer, parent=None):
     value = property_get(self.source, parent)
     self.property_set(self.target, parent, value)
Example #5
0
 def remove(self, instance):
     store = property_get(self.store, instance)
     return store.remove_object(instance, self.offset, self.size)
Example #6
0
 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)
Example #7
0
 def get(self, instance):
     store = property_get(self.store, instance)
     return store.get_object(instance, self.offset, self.size)
Example #8
0
 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)
Example #9
0
 def get_size(self, parent=None):
     value = property_get(self.target, parent)
     return self.field.get_size(value, parent)
Example #10
0
 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
Example #11
0
 def remove( self, instance ):
     store = property_get( self.store, instance )
     return store.remove_object( instance, self.offset, self.size )
Example #12
0
 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 )
Example #13
0
 def get( self, instance ):
     store = property_get( self.store, instance )
     return store.get_object( instance, self.offset, self.size )
Example #14
0
 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 )