(self, offset, size_or_format)
return ret
Read data at `offset', or raise an exception.  `size_or_format'
           may either be a byte count, in which case we return raw data,
           or a format string for `struct.unpack', in which case we
           work out the size and unpack the data before returning it.
Read data at `offset', or raise an exception.  `size_or_format'
           may either be a byte count, in which case we return raw data,
           or a format string for `struct.unpack', in which case we
           work out the size and unpack the data before returning it.
Read data at offset or raise an exception . size_or_format may either be a byte count in which case we return raw data or a format string for struct . unpack in which case we work out the size and unpack the data before returning it .
def read(self, offset, size_or_format):
        """Read data at `offset', or raise an exception.  `size_or_format'
           may either be a byte count, in which case we return raw data,
           or a format string for `struct.unpack', in which case we
           work out the size and unpack the data before returning it."""
        # N.B. There is a fixed offset of four bytes(!)
        self._file.seek(offset + 4, os.SEEK_SET)

        if isinstance(size_or_format, (str, unicode)):
            size = struct.calcsize(size_or_format)
            fmt = size_or_format
        else:
            size = size_or_format
            fmt = None
        
        ret = self._file.read(size)
        if len(ret) < size:
            ret += b'\0' * (size - len(ret))

        if fmt is not None:
            if isinstance(ret, bytearray):
                ret = struct.unpack_from(fmt, bytes(ret))
            else:
                ret = struct.unpack(fmt, ret)
            
        return ret
def read ( self , offset , size_or_format ) : # N.B. There is a fixed offset of four bytes(!) self . _file . seek ( offset + 4 , os . SEEK_SET ) if isinstance ( size_or_format , ( str , unicode ) ) : size = struct . calcsize ( size_or_format ) fmt = size_or_format else : size = size_or_format fmt = None ret = self . _file . read ( size ) if len ( ret ) < size : ret += b'\0' * ( size - len ( ret ) ) if fmt is not None : if isinstance ( ret , bytearray ) : ret = struct . unpack_from ( fmt , bytes ( ret ) ) else : ret = struct . unpack ( fmt , ret ) return ret