def parseMobiHeader(self):
    headerfmt = '> IIII II 40s III IIIII IIII I 36s IIII 8s HHIIIII'
    headerlen = calcsize(headerfmt)
    fields = ['identifier', 'header length', 'Mobi type', 'text Encoding', 'Unique-ID', 'Generator version', '-Reserved', 'First Non-book index', 'Full Name Offset', 'Full Name Length', 'Language', 'Input Language', 'Output Language', 'Format version', 'First Image index', 'First Huff Record', 'Huff Record Count', 'First DATP Record', 'DATP Record Count', 'EXTH flags', '-36 unknown bytes, if Mobi is long enough', 'DRM Offset', 'DRM Count', 'DRM Size', 'DRM Flags', '-Usually Zeros, unknown 8 bytes', '-Unknown', 'Last Image Record', '-Unknown', 'FCIS record', '-Unknown', 'FLIS record', 'Unknown']
    results = zip(fields, unpack(headerfmt, self.contents[self.offset:(self.offset + headerlen)]))
    resultsDict = utils.toDict(results)
    resultsDict['Start Offset'] = self.offset
    resultsDict['Full Name'] = self.contents[(self.records[0]['record Data Offset'] + resultsDict['Full Name Offset']):((self.records[0]['record Data Offset'] + resultsDict['Full Name Offset']) + resultsDict['Full Name Length'])]
    resultsDict['Has DRM'] = (resultsDict['DRM Offset'] != 4294967295)
    resultsDict['Has EXTH Header'] = ((resultsDict['EXTH flags'] & 64) != 0)
    self.offset += resultsDict['header length']

    def onebits(x, width=16):
        return len(list(filter((lambda x: (x == '1')), (str(((x >> i) & 1)) for i in range((width - 1), (- 1), (- 1))))))
    resultsDict['extra bytes'] = (2 * onebits((unpack('>H', self.contents[(self.offset - 2):self.offset])[0] & 65534)))
    return resultsDict
def parseMobiHeader(self):
    headerfmt = '> IIII II 40s III IIIII IIII I 36s IIII 8s HHIIIII'
    headerlen = calcsize(headerfmt)
    fields = ['identifier', 'header length', 'Mobi type', 'text Encoding', 'Unique-ID', 'Generator version', '-Reserved', 'First Non-book index', 'Full Name Offset', 'Full Name Length', 'Language', 'Input Language', 'Output Language', 'Format version', 'First Image index', 'First Huff Record', 'Huff Record Count', 'First DATP Record', 'DATP Record Count', 'EXTH flags', '-36 unknown bytes, if Mobi is long enough', 'DRM Offset', 'DRM Count', 'DRM Size', 'DRM Flags', '-Usually Zeros, unknown 8 bytes', '-Unknown', 'Last Image Record', '-Unknown', 'FCIS record', '-Unknown', 'FLIS record', 'Unknown']
    results = zip(fields, unpack(headerfmt, self.contents[self.offset:(self.offset + headerlen)]))
    resultsDict = utils.toDict(results)
    resultsDict['Start Offset'] = self.offset
    resultsDict['Full Name'] = self.contents[(self.records[0]['record Data Offset'] + resultsDict['Full Name Offset']):((self.records[0]['record Data Offset'] + resultsDict['Full Name Offset']) + resultsDict['Full Name Length'])]
    resultsDict['Has DRM'] = (resultsDict['DRM Offset'] != 4294967295)
    resultsDict['Has EXTH Header'] = ((resultsDict['EXTH flags'] & 64) != 0)
    self.offset += resultsDict['header length']

    def onebits(x, width=16):
        return len(list(filter((lambda x: (x == '1')), (str(((x >> i) & 1)) for i in range((width - 1), (- 1), (- 1))))))
    resultsDict['extra bytes'] = (2 * onebits((unpack('>H', self.contents[(self.offset - 2):self.offset])[0] & 65534)))
    return resultsDict