This commit is contained in:
Kovid Goyal 2007-05-16 03:56:10 +00:00
parent 32088f598b
commit 765a83fa39
4 changed files with 14 additions and 0 deletions

View File

@ -41,6 +41,8 @@ def extract(filename, dir):
prefix = dirname
# extract files
for fn in filelist:
if not os.path.exists(os.path.dirname(fn)):
os.makedirs(os.path.dirname(fn))
out = open( fn, 'wb' )
buffer = StringIO( zf.read( fn ))
buflen = 2 ** 20

View File

@ -60,6 +60,8 @@ def option_parser(usage):
help='Sort key for the title')
metadata.add_option('--author-sort', action='store', default='', dest='author_sort',
help='Sort key for the author')
metadata.add_option('--publisher', action='store', default='Unknown', dest='publisher',
help='Publisher')
profiles=['prs500']
parser.add_option('-o', '--output', action='store', default=None, \
help='Output file name. Default is derived from input filename')

View File

@ -1055,6 +1055,7 @@ def process_file(path, options):
args = dict(font_delta=options.font_delta, title=title, \
author=author, sourceencoding='utf8',\
freetext=options.freetext, category=options.category,
publisher=options.publisher,
booksetting=BookSetting(dpi=10*options.profile.dpi,
screenheight=options.profile.screen_height,
screenwidth=options.profile.screen_width))
@ -1115,6 +1116,14 @@ def try_opf(path, options):
fa = author.get('file-as')
if fa:
options.author_sort = fa
if options.publisher == 'Unknown':
publisher = soup.package.metadata.find('dc:publisher')
if publisher:
options.publisher = publisher.string
if not options.category.strip():
category = soup.package.metadata.find('dc:type')
if category:
options.category = category.string
isbn = []
for item in soup.package.metadata.findAll('dc:identifier'):
scheme = item.get('scheme')

View File

@ -73,6 +73,7 @@ def convert_txt(path, options):
title = (options.title, options.title_sort)
author = (options.author, options.author_sort)
book = Book(header=header, title=title, author=author, \
publisher=options.publisher,
sourceencoding=options.encoding, freetext=options.freetext, \
category=options.category, booksetting=BookSetting
(dpi=10*options.profile.dpi,