コード例 #1
0
    def __init__(self, _file):
        """
        _file: can be either a path to a file (a string) or a file-like object.
        """
        self._file = _file
        self._zobject = None
        self._opfpath = None
        self._ncxpath = None
        self._basepath = None
        self._tempdir = tempfile.mkdtemp()

        if not self._verify():
            print 'Warning: This does not seem to be a valid epub file'

        self._get_opf()
        self._get_ncx()

        ncxfile = self._zobject.open(self._ncxpath)
        opffile = self._zobject.open(self._opfpath)
        self._navmap = navmap.NavMap(opffile, ncxfile, self._basepath)

        opffile = self._zobject.open(self._opfpath)
        self._info = epubinfo.EpubInfo(opffile)

        self._unzip()
コード例 #2
0
    def __init__(self, filepath):
        self._filepath = filepath
        self._zobject = None
        self._opfpath = None
        self._ncxpath = None
        self._basepath = None
        self._tempdir = tempfile.mkdtemp()

        if not self._verify():
            print 'Warning: This does not seem to be a valid epub file'

        self._get_opf()
        self._get_ncx()

        ncxfile = self._zobject.open(self._ncxpath)
        opffile = self._zobject.open(self._opfpath)
        self._navmap = navmap.NavMap(opffile, ncxfile, self._basepath)

        opffile = self._zobject.open(self._opfpath)
        self._info = epubinfo.EpubInfo(opffile)

        self._unzip()