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 '''
|
help='''Profile of the target device for which this LRF is '''
|
||||||
'''being generated. Default: ''' + profiles[0] + '''
|
'''being generated. Default: ''' + profiles[0] + '''
|
||||||
Supported profiles: '''+', '.join(profiles))
|
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
|
return parser
|
||||||
|
|
||||||
def Book(font_delta=0, header=None, profile=PRS500_PROFILE, **settings):
|
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 = parser.add_option_group('PREPROCESSING OPTIONS')
|
||||||
prepro.add_option('--baen', action='store_true', default=False, dest='baen',
|
prepro.add_option('--baen', action='store_true', default=False, dest='baen',
|
||||||
help='''Preprocess Baen HTML files to improve generated LRF.''')
|
help='''Preprocess Baen HTML files to improve generated LRF.''')
|
||||||
debug = parser.add_option_group('DEBUG OPTIONS')
|
debug = None
|
||||||
debug.add_option('--verbose', dest='verbose', action='store_true', default=False,
|
for g in parser.option_groups:
|
||||||
help='''Be verbose while processing''')
|
if g.title == 'DEBUG OPTIONS':
|
||||||
debug.add_option('--lrs', action='store_true', dest='lrs', \
|
debug = g
|
||||||
help='Convert to LRS', default=False)
|
|
||||||
debug.add_option('--show-broken-links', dest='show_broken_links', action='store_true',
|
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''')
|
default=False, help='''Show the href of broken links in generated LRF''')
|
||||||
options, args = parser.parse_args(args=argv)
|
options, args = parser.parse_args(args=argv)
|
||||||
|
@ -53,7 +53,7 @@ def main():
|
|||||||
src = os.path.abspath(os.path.expanduser(args[0]))
|
src = os.path.abspath(os.path.expanduser(args[0]))
|
||||||
except:
|
except:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
convert_txt(src, options)
|
print 'Output written to ', convert_txt(src, options)
|
||||||
|
|
||||||
|
|
||||||
def convert_txt(path, options):
|
def convert_txt(path, options):
|
||||||
@ -77,7 +77,7 @@ def convert_txt(path, options):
|
|||||||
category=options.category, booksetting=BookSetting
|
category=options.category, booksetting=BookSetting
|
||||||
(dpi=10*options.profile.dpi,
|
(dpi=10*options.profile.dpi,
|
||||||
screenheight=options.profile.screen_height,
|
screenheight=options.profile.screen_height,
|
||||||
screenwidth=options.profile.screen_height))
|
screenwidth=options.profile.screen_width))
|
||||||
buffer = ''
|
buffer = ''
|
||||||
pg = book.create_page()
|
pg = book.create_page()
|
||||||
block = book.create_text_block()
|
block = book.create_text_block()
|
||||||
@ -92,11 +92,11 @@ def convert_txt(path, options):
|
|||||||
buffer = ''
|
buffer = ''
|
||||||
basename = os.path.basename(path)
|
basename = os.path.basename(path)
|
||||||
oname = options.output
|
oname = options.output
|
||||||
oname = os.path.abspath(os.path.expanduser(oname))
|
|
||||||
if not oname:
|
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:
|
try:
|
||||||
book.renderLrf(oname)
|
book.renderLrs(oname) if options.lrs else book.renderLrf(oname)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
raise ConversionError(path + ' is not encoded in ' + \
|
raise ConversionError(path + ' is not encoded in ' + \
|
||||||
options.encoding +'. Specify the '+ \
|
options.encoding +'. Specify the '+ \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user