mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #64
This commit is contained in:
parent
ebe46a8c5a
commit
a4acd60399
@ -68,6 +68,11 @@ def option_parser(usage):
|
||||
help='''Profile of the target device for which this LRF is '''
|
||||
'''being generated. Default: ''' + profiles[0] + '''
|
||||
Supported profiles: '''+', '.join(profiles))
|
||||
debug = parser.add_option_group('DEBUG OPTIONS')
|
||||
debug.add_option('--verbose', dest='verbose', action='store_true', default=False,
|
||||
help='''Be verbose while processing''')
|
||||
debug.add_option('--lrs', action='store_true', dest='lrs', \
|
||||
help='Convert to LRS', default=False)
|
||||
return parser
|
||||
|
||||
def Book(font_delta=0, header=None, profile=PRS500_PROFILE, **settings):
|
||||
|
@ -1109,11 +1109,10 @@ def parse_options(argv=None, cli=True):
|
||||
prepro = parser.add_option_group('PREPROCESSING OPTIONS')
|
||||
prepro.add_option('--baen', action='store_true', default=False, dest='baen',
|
||||
help='''Preprocess Baen HTML files to improve generated LRF.''')
|
||||
debug = parser.add_option_group('DEBUG OPTIONS')
|
||||
debug.add_option('--verbose', dest='verbose', action='store_true', default=False,
|
||||
help='''Be verbose while processing''')
|
||||
debug.add_option('--lrs', action='store_true', dest='lrs', \
|
||||
help='Convert to LRS', default=False)
|
||||
debug = None
|
||||
for g in parser.option_groups:
|
||||
if g.title == 'DEBUG OPTIONS':
|
||||
debug = g
|
||||
debug.add_option('--show-broken-links', dest='show_broken_links', action='store_true',
|
||||
default=False, help='''Show the href of broken links in generated LRF''')
|
||||
options, args = parser.parse_args(args=argv)
|
||||
|
@ -53,7 +53,7 @@ def main():
|
||||
src = os.path.abspath(os.path.expanduser(args[0]))
|
||||
except:
|
||||
sys.exit(1)
|
||||
convert_txt(src, options)
|
||||
print 'Output written to ', convert_txt(src, options)
|
||||
|
||||
|
||||
def convert_txt(path, options):
|
||||
@ -77,7 +77,7 @@ def convert_txt(path, options):
|
||||
category=options.category, booksetting=BookSetting
|
||||
(dpi=10*options.profile.dpi,
|
||||
screenheight=options.profile.screen_height,
|
||||
screenwidth=options.profile.screen_height))
|
||||
screenwidth=options.profile.screen_width))
|
||||
buffer = ''
|
||||
pg = book.create_page()
|
||||
block = book.create_text_block()
|
||||
@ -91,12 +91,12 @@ def convert_txt(path, options):
|
||||
block.Paragraph(buffer)
|
||||
buffer = ''
|
||||
basename = os.path.basename(path)
|
||||
oname = options.output
|
||||
oname = os.path.abspath(os.path.expanduser(oname))
|
||||
oname = options.output
|
||||
if not oname:
|
||||
oname = os.path.splitext(basename)[0]+'.lrf'
|
||||
oname = os.path.splitext(basename)[0]+('.lrs' if options.lrs else '.lrf')
|
||||
oname = os.path.abspath(os.path.expanduser(oname))
|
||||
try:
|
||||
book.renderLrf(oname)
|
||||
book.renderLrs(oname) if options.lrs else book.renderLrf(oname)
|
||||
except UnicodeDecodeError:
|
||||
raise ConversionError(path + ' is not encoded in ' + \
|
||||
options.encoding +'. Specify the '+ \
|
||||
|
Loading…
x
Reference in New Issue
Block a user