mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Various minor bug fixes. Fixes #1053 (Problem converting html to Epub)
This commit is contained in:
parent
f3eebb473f
commit
eadb7172c4
@ -74,7 +74,7 @@ MAP = {
|
|||||||
'txt' : txt2opf,
|
'txt' : txt2opf,
|
||||||
'pdf' : pdf2opf,
|
'pdf' : pdf2opf,
|
||||||
}
|
}
|
||||||
SOURCE_FORMATS = ['lit', 'mobi', 'prc', 'fb2', 'rtf', 'txt', 'pdf', 'rar', 'zip', 'htm', 'html']
|
SOURCE_FORMATS = ['lit', 'mobi', 'prc', 'fb2', 'rtf', 'txt', 'pdf', 'rar', 'zip', 'oebzip', 'htm', 'html']
|
||||||
|
|
||||||
def unarchive(path, tdir):
|
def unarchive(path, tdir):
|
||||||
extract(path, tdir)
|
extract(path, tdir)
|
||||||
@ -109,7 +109,7 @@ def any2epub(opts, path, notification=None):
|
|||||||
opts.output = os.path.splitext(os.path.basename(path))[0]+'.epub'
|
opts.output = os.path.splitext(os.path.basename(path))[0]+'.epub'
|
||||||
|
|
||||||
with nested(TemporaryDirectory('_any2epub1'), TemporaryDirectory('_any2epub2')) as (tdir1, tdir2):
|
with nested(TemporaryDirectory('_any2epub1'), TemporaryDirectory('_any2epub2')) as (tdir1, tdir2):
|
||||||
if ext in ['rar', 'zip']:
|
if ext in ['rar', 'zip', 'oebzip']:
|
||||||
path, ext = unarchive(path, tdir1)
|
path, ext = unarchive(path, tdir1)
|
||||||
print 'Found %s file in archive'%(ext.upper())
|
print 'Found %s file in archive'%(ext.upper())
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ def config(defaults=None):
|
|||||||
|
|
||||||
|
|
||||||
def formats():
|
def formats():
|
||||||
return ['html', 'rar', 'zip']+list(MAP.keys())
|
return ['html', 'rar', 'zip', 'oebzip']+list(MAP.keys())
|
||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
|
|
||||||
@ -151,4 +151,4 @@ def main(args=sys.argv):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
@ -491,17 +491,21 @@ class Processor(Parser):
|
|||||||
|
|
||||||
referrer = toc
|
referrer = toc
|
||||||
if self.htmlfile.referrer is not None:
|
if self.htmlfile.referrer is not None:
|
||||||
name = self.htmlfile_map[self.htmlfile.referrer]
|
try:
|
||||||
href = 'content/'+name
|
name = self.htmlfile_map[self.htmlfile.referrer]
|
||||||
for i in toc.flat():
|
href = 'content/'+name
|
||||||
if href == i.href and i.fragment is None:
|
for i in toc.flat():
|
||||||
referrer = i
|
if href == i.href and i.fragment is None:
|
||||||
break
|
referrer = i
|
||||||
|
break
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
name = self.htmlfile_map[self.htmlfile.path]
|
name = self.htmlfile_map[self.htmlfile.path]
|
||||||
href = 'content/'+name
|
href = 'content/'+name
|
||||||
|
|
||||||
|
|
||||||
if referrer.href != href: # Happens for root file
|
if referrer.href != href: # Happens for root file
|
||||||
target = add_item(href, None, unicode(self.htmlfile.title), referrer, type='file')
|
target = add_item(href, None, unicode(self.htmlfile.title), referrer, type='file')
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ def config(defaults=None):
|
|||||||
help=_('Set the author in the metadata of the generated ebook. Default is %default'),
|
help=_('Set the author in the metadata of the generated ebook. Default is %default'),
|
||||||
default=_('Unknown'))
|
default=_('Unknown'))
|
||||||
c.add_opt('output', ['-o', '--output'],
|
c.add_opt('output', ['-o', '--output'],
|
||||||
help=_('Path to output LRF file. By default a file is created in the current directory.'))
|
help=_('Path to output file. By default a file is created in the current directory.'))
|
||||||
c.add_opt('colors', ['-c', '--colors'], type='int', default=64,
|
c.add_opt('colors', ['-c', '--colors'], type='int', default=64,
|
||||||
help=_('Number of colors for grayscale image conversion. Default: %default'))
|
help=_('Number of colors for grayscale image conversion. Default: %default'))
|
||||||
c.add_opt('dont_normalize', ['-n', '--disable-normalize'], default=False,
|
c.add_opt('dont_normalize', ['-n', '--disable-normalize'], default=False,
|
||||||
@ -306,7 +306,7 @@ def config(defaults=None):
|
|||||||
c.add_opt('no_sort', ['--no-sort'], default=False,
|
c.add_opt('no_sort', ['--no-sort'], default=False,
|
||||||
help=_("Don't sort the files found in the comic alphabetically by name. Instead use the order they were added to the comic."))
|
help=_("Don't sort the files found in the comic alphabetically by name. Instead use the order they were added to the comic."))
|
||||||
c.add_opt('profile', ['-p', '--profile'], default='prs500', choices=PROFILES.keys(),
|
c.add_opt('profile', ['-p', '--profile'], default='prs500', choices=PROFILES.keys(),
|
||||||
help=_('Choose a profile for the device you are generating this LRF for. The default is the SONY PRS-500 with a screen size of 584x754 pixels. Choices are %s')%PROFILES.keys())
|
help=_('Choose a profile for the device you are generating this file for. The default is the SONY PRS-500 with a screen size of 584x754 pixels. This is suitable for any reader with the same screen size. Choices are %s')%PROFILES.keys())
|
||||||
c.add_opt('verbose', ['-v', '--verbose'], default=0, action='count',
|
c.add_opt('verbose', ['-v', '--verbose'], default=0, action='count',
|
||||||
help=_('Be verbose, useful for debugging. Can be specified multiple times for greater verbosity.'))
|
help=_('Be verbose, useful for debugging. Can be specified multiple times for greater verbosity.'))
|
||||||
c.add_opt('no_progress_bar', ['--no-progress-bar'], default=False,
|
c.add_opt('no_progress_bar', ['--no-progress-bar'], default=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user