# Path: resources/lib/kindleunpack/compatibility_utils.py
# def unicode_str(p, enc='utf-8'):
#     if p is None:
#         return None
#     if isinstance(p, text_type):
#         return p
#     return p.decode(enc)
# 
# def unescapeit(sval):
#     return _h.unescape(sval)
# 
# Path: resources/lib/kindleunpack/compatibility_utils.py
# def lzip(*args, **kwargs):
#     return list(zip(*args, **kwargs))
# 
# Path: resources/lib/kindleunpack/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


from .compatibility_utils import unicode_str, unescapeit
from .compatibility_utils import lzip
from .unipath import pathof
from xml.sax.saxutils import escape as xmlescape
from datetime import datetime
import os
import uuid
            self.target_epubver = self.autodetectEPUBVersion()
        elif self.epubver == 'F':
            self.target_epubver = '2'
        elif self.epubver != '2' and self.epubver != '3':
            self.target_epubver = '2'

        # id for rifine attributes
        self.title_id = {}
        self.creator_id = {}
        self.publisher_id = {}
        # extra attributes
        self.title_attrib = {}
        self.creator_attrib = {}
        self.publisher_attrib = {}
        self.extra_attributes = []  # for force epub2 option
        # Create epub3 metadata from EXTH.
        self.exth_solved_refines_metadata = []
        self.exth_refines_metadata = []
        self.exth_fixedlayout_metadata = []

        self.defineRefinesID()
        self.processRefinesMetadata()
        if self.k8resc is not None:
            # Create metadata in RESC section.
            self.k8resc.createMetadata(epubver)
        if self.target_epubver == "3":
            self.createMetadataForFixedlayout()

    def escapeit(self, sval, EXTRAS=None):
        # note, xmlescape and unescape do not work with utf-8 bytestrings

# Path: resources/lib/kindleunpack/compatibility_utils.py
# def unicode_str(p, enc='utf-8'):
#     if p is None:
#         return None
#     if isinstance(p, text_type):
#         return p
#     return p.decode(enc)
# 
# def unescapeit(sval):
#     return _h.unescape(sval)
# 
# Path: resources/lib/kindleunpack/compatibility_utils.py
# def lzip(*args, **kwargs):
#     return list(zip(*args, **kwargs))
# 
# Path: resources/lib/kindleunpack/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: resources/lib/kindleunpack/mobi_opf.py
from .compatibility_utils import unicode_str, unescapeit
from .compatibility_utils import lzip
from .unipath import pathof
from xml.sax.saxutils import escape as xmlescape
from datetime import datetime
import os
import uuid

            self.target_epubver = self.autodetectEPUBVersion()
        elif self.epubver == 'F':
            self.target_epubver = '2'
        elif self.epubver != '2' and self.epubver != '3':
            self.target_epubver = '2'

        # id for rifine attributes
        self.title_id = {}
        self.creator_id = {}
        self.publisher_id = {}
        # extra attributes
        self.title_attrib = {}
        self.creator_attrib = {}
        self.publisher_attrib = {}
        self.extra_attributes = []  # for force epub2 option
        # Create epub3 metadata from EXTH.
        self.exth_solved_refines_metadata = []
        self.exth_refines_metadata = []
        self.exth_fixedlayout_metadata = []

        self.defineRefinesID()
        self.processRefinesMetadata()
        if self.k8resc is not None:
            # Create metadata in RESC section.
            self.k8resc.createMetadata(epubver)
        if self.target_epubver == "3":
            self.createMetadataForFixedlayout()

    def escapeit(self, sval, EXTRAS=None):
        # note, xmlescape and unescape do not work with utf-8 bytestrings

        sval = unicode_str(sval)