# Path: modules/unipath.py
# def pathof(s, enc=fsencoding):
#     if s is None:
#         return None
#     if isinstance(s, text_type):
#         return s
#     if isinstance(s, binary_type):
#         try:
#             return s.decode(enc)
#         except:
#             pass
#     return s


import struct
import string
import re
from PIL import Image
from io import BytesIO
from .unipath import pathof
            #     datain_kfrec0 = add_exth(datain_kfrec0, exth_asin, bytes(to_base(document_id.int, base=32, min_num_digits=10), 'ascii'))
            exth = read_exth(datain_kfrec0, exth_cdecontentkey)
            if len(exth) == 0:
                datain_kfrec0 = add_exth(datain_kfrec0, exth_cdecontentkey, bytes(to_base(document_id.int, base=32, min_num_digits=10), 'ascii'))

            self.result_file8 = writesection(self.result_file8, 0, datain_kfrec0)

            # mobi8 finished

    def getResult(self):
        return self.result_file

    def getResult8(self):
        return self.result_file8

    def getResult7(self):
        return self.result_file7


class mobi_read:
    def __init__(self, infile, width=330, height=470, stretch=False):

        self.asin = ''
        self.cdetype = 'PDOC'
        self.cdecontentkey = ''
        self.acr = ''
        self.thumbnail = None
        self.pagedata = b''

        datain = b''

# Path: modules/unipath.py
# def pathof(s, enc=fsencoding):
#     if s is None:
#         return None
#     if isinstance(s, text_type):
#         return s
#     if isinstance(s, binary_type):
#         try:
#             return s.decode(enc)
#         except:
#             pass
#     return s


# Path: modules/mobi_split.py
import struct
import string
import re
from PIL import Image
from io import BytesIO
from .unipath import pathof

            #     datain_kfrec0 = add_exth(datain_kfrec0, exth_asin, bytes(to_base(document_id.int, base=32, min_num_digits=10), 'ascii'))
            exth = read_exth(datain_kfrec0, exth_cdecontentkey)
            if len(exth) == 0:
                datain_kfrec0 = add_exth(datain_kfrec0, exth_cdecontentkey, bytes(to_base(document_id.int, base=32, min_num_digits=10), 'ascii'))

            self.result_file8 = writesection(self.result_file8, 0, datain_kfrec0)

            # mobi8 finished

    def getResult(self):
        return self.result_file

    def getResult8(self):
        return self.result_file8

    def getResult7(self):
        return self.result_file7


class mobi_read:
    def __init__(self, infile, width=330, height=470, stretch=False):

        self.asin = ''
        self.cdetype = 'PDOC'
        self.cdecontentkey = ''
        self.acr = ''
        self.thumbnail = None
        self.pagedata = b''

        datain = b''

        with open(pathof(infile), 'rb') as f: