Implement #991 (Add .oebzip extension)

This commit is contained in:
Kovid Goyal 2008-08-31 20:08:55 -07:00
parent d8e02cc76b
commit 5d3393d075
3 changed files with 6 additions and 6 deletions

View File

@ -95,7 +95,7 @@ def filename_to_utf8(name):
def extract(path, dir):
ext = os.path.splitext(path)[1][1:].lower()
extractor = None
if ext in ['zip', 'cbz', 'epub']:
if ext in ['zip', 'cbz', 'epub', 'oebzip']:
from calibre.libunzip import extract as zipextract
extractor = zipextract
elif ext in ['cbr', 'rar']:

View File

@ -18,4 +18,4 @@ class UnknownFormatError(Exception):
BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm', 'xhtm',
'html', 'xhtml', 'epub', 'pdf', 'prc', 'mobi', 'azw',
'epub', 'fb2', 'djvu', 'lrx', 'cbr', 'cbz']
'epub', 'fb2', 'djvu', 'lrx', 'cbr', 'cbz', 'oebzip']

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''Convert any ebook file into a LRF file.'''
import sys, os, logging, shutil, tempfile, glob, re
import sys, os, logging, shutil, tempfile, re
from calibre.ebooks import UnknownFormatError
from calibre.ebooks.lrf import option_parser as _option_parser
@ -30,7 +30,7 @@ def find_htmlfile(dir):
toc_pat = re.compile(r'toc', re.IGNORECASE)
toc_files, files = [], []
for f in map(lambda x:os.path.join(dir, x), os.listdir(dir)):
name, ext = os.path.splitext(f)
ext = os.path.splitext(f)[1]
if ext and ext_pat.match(ext):
toc_files.append(f) if toc_pat.search(f) else files.append(f)
a = toc_files if toc_files else files
@ -74,7 +74,7 @@ def handle_archive(path):
candidates = map(lambda x:os.path.join(cdir, x), os.listdir(cdir))
for ext in exts:
for f in candidates:
if f.lower().endswith(ext):
if f.lower().endswith('.'+ext):
files.append(f)
file = largest_file(files)
if not file:
@ -103,7 +103,7 @@ def process_file(path, options, logger=None):
fmt = '.lrs' if options.lrs else '.lrf'
options.output = os.path.splitext(os.path.basename(path))[0] + fmt
options.output = os.path.abspath(os.path.expanduser(options.output))
if ext in ['zip', 'rar']:
if ext in ['zip', 'rar', 'oebzip']:
newpath = None
try:
tdir, newpath = handle_archive(path)