(self, dbfile, length=None, magic=b("HSH3"), startoffset=0)
:param dbfile: a :class:`~whoosh.filedb.structfile.StructFile` object
            to read from.
        :param length: the length of the file data. This is necessary since the
            hashing information is written at the end of the file.
        :param magic: the format tag bytes to look for at the start of the
            file. If the file's format tag does not match these bytes, the
            object raises a :class:`FileFormatError` exception.
        :param startoffset: the starting point of the file data.
:param dbfile: a :class:`~whoosh.filedb.structfile.StructFile` object
            to read from.
        :param length: the length of the file data. This is necessary since the
            hashing information is written at the end of the file.
        :param magic: the format tag bytes to look for at the start of the
            file. If the file's format tag does not match these bytes, the
            object raises a :class:`FileFormatError` exception.
        :param startoffset: the starting point of the file data.
: param dbfile : a : class : ~whoosh . filedb . structfile . StructFile object to read from . : param length : the length of the file data . This is necessary since the hashing information is written at the end of the file . : param magic : the format tag bytes to look for at the start of the file . If the file s format tag does not match these bytes the object raises a : class : FileFormatError exception . : param startoffset : the starting point of the file data .
def __init__(self, dbfile, length=None, magic=b("HSH3"), startoffset=0):
        """
        :param dbfile: a :class:`~whoosh.filedb.structfile.StructFile` object
            to read from.
        :param length: the length of the file data. This is necessary since the
            hashing information is written at the end of the file.
        :param magic: the format tag bytes to look for at the start of the
            file. If the file's format tag does not match these bytes, the
            object raises a :class:`FileFormatError` exception.
        :param startoffset: the starting point of the file data.
        """

        self.dbfile = dbfile
        self.startoffset = startoffset
        self.is_closed = False

        if length is None:
            dbfile.seek(0, os.SEEK_END)
            length = dbfile.tell() - startoffset

        dbfile.seek(startoffset)
        # Check format tag
        filemagic = dbfile.read(4)
        if filemagic != magic:
            raise FileFormatError("Unknown file header %r" % filemagic)
        # Read hash type
        self.hashtype = dbfile.read_byte()
        self.hashfn = _hash_functions[self.hashtype]
        # Skip unused future expansion bits
        dbfile.read_int()
        dbfile.read_int()
        self.startofdata = dbfile.tell()

        exptr = startoffset + length - _INT_SIZE
        # Get the length of extras from the end of the file
        exlen = dbfile.get_int(exptr)
        # Read the extras
        expos = exptr - exlen
        dbfile.seek(expos)
        self._read_extras()

        # Calculate the directory base from the beginning of the extras
        dbfile.seek(expos - _directory_size)
        # Read directory of hash tables
        self.tables = []
        entrysize = _dir_entry.size
        unpackentry = _dir_entry.unpack
        for _ in xrange(256):
            # position, numslots
            self.tables.append(unpackentry(dbfile.read(entrysize)))
        # The position of the first hash table is the end of the key/value pairs
        self.endofdata = self.tables[0][0]
def __init__ ( self , dbfile , length = None , magic = b ( "HSH3" ) , startoffset = 0 ) : self . dbfile = dbfile self . startoffset = startoffset self . is_closed = False if length is None : dbfile . seek ( 0 , os . SEEK_END ) length = dbfile . tell ( ) - startoffset dbfile . seek ( startoffset ) # Check format tag filemagic = dbfile . read ( 4 ) if filemagic != magic : raise FileFormatError ( "Unknown file header %r" % filemagic ) # Read hash type self . hashtype = dbfile . read_byte ( ) self . hashfn = _hash_functions [ self . hashtype ] # Skip unused future expansion bits dbfile . read_int ( ) dbfile . read_int ( ) self . startofdata = dbfile . tell ( ) exptr = startoffset + length - _INT_SIZE # Get the length of extras from the end of the file exlen = dbfile . get_int ( exptr ) # Read the extras expos = exptr - exlen dbfile . seek ( expos ) self . _read_extras ( ) # Calculate the directory base from the beginning of the extras dbfile . seek ( expos - _directory_size ) # Read directory of hash tables self . tables = [ ] entrysize = _dir_entry . size unpackentry = _dir_entry . unpack for _ in xrange ( 256 ) : # position, numslots self . tables . append ( unpackentry ( dbfile . read ( entrysize ) ) ) # The position of the first hash table is the end of the key/value pairs self . endofdata = self . tables [ 0 ] [ 0 ]