home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from __future__ import with_statement
- __license__ = 'GPL v3'
- __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
- import os
- from calibre.utils.zipfile import ZipFile
- from calibre.ptempfile import TemporaryDirectory
- from calibre import CurrentDir
-
- def get_metadata(stream):
- get_metadata = get_metadata
- import calibre.ebooks.metadata.meta
- is_comic = is_comic
- import calibre.ebooks.metadata.archive
- stream_type = None
- zf = ZipFile(stream, 'r')
- names = zf.namelist()
- if is_comic(names):
- return get_metadata(stream, 'cbz')
- for f in names:
- stream_type = os.path.splitext(f)[1].lower()
- if stream_type:
- stream_type = stream_type[1:]
- if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', 'rb', 'imp', 'pdf', 'lrf', 'azw'):
-
- try:
- tdir = _[1]
- CurrentDir(tdir).__enter__()
-
- try:
- path = zf.extract(f)
- return get_metadata(open(path, 'rb'), stream_type)
- finally:
- pass
-
- finally:
- pass
-
-
- stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', 'rb', 'imp', 'pdf', 'lrf', 'azw')
-
- raise ValueError('No ebook found in ZIP archive')
-
-