mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Added a --with-library option to the calibre GUI so that it can be easily used with multiple libraries
This commit is contained in:
parent
4f4bf0ec02
commit
0114f4cf20
@ -24,9 +24,9 @@ _('''%prog [options] mybook.txt
|
|||||||
dest='debug_html_generation', help=_('Print generated HTML to stdout and quit.'))
|
dest='debug_html_generation', help=_('Print generated HTML to stdout and quit.'))
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def fix_image_includes(tdir, match):
|
def fix_image_includes(sdir, tdir, match):
|
||||||
path = match.group(1).split('/')
|
path = match.group(1).split('/')
|
||||||
src = os.path.join(os.getcwd(), *path)
|
src = os.path.join(sdir, *path)
|
||||||
dest = os.path.join(tdir, *path)
|
dest = os.path.join(tdir, *path)
|
||||||
p = os.path.dirname(dest)
|
p = os.path.dirname(dest)
|
||||||
if not os.path.exists(p):
|
if not os.path.exists(p):
|
||||||
@ -64,7 +64,7 @@ def generate_html(txtfile, encoding, tdir):
|
|||||||
)
|
)
|
||||||
html = '<html><body>'+md.convert(txt)+'</body></html>'
|
html = '<html><body>'+md.convert(txt)+'</body></html>'
|
||||||
for match in re.finditer(r'<img\s+[^>]*src="([^"]+)"', html):
|
for match in re.finditer(r'<img\s+[^>]*src="([^"]+)"', html):
|
||||||
fix_image_includes(tdir, match)
|
fix_image_includes(os.path.dirname(txtfile), tdir, match)
|
||||||
p = os.path.join(tdir, 'index.html')
|
p = os.path.join(tdir, 'index.html')
|
||||||
open(p, 'wb').write(html.encode('utf-8'))
|
open(p, 'wb').write(html.encode('utf-8'))
|
||||||
mi = MetaInformation(os.path.splitext(os.path.basename(txtfile))[0], [_('Unknown')])
|
mi = MetaInformation(os.path.splitext(os.path.basename(txtfile))[0], [_('Unknown')])
|
||||||
|
@ -1252,7 +1252,12 @@ def main(args=sys.argv):
|
|||||||
Launch the main calibre Graphical User Interface and optionally add the ebook at
|
Launch the main calibre Graphical User Interface and optionally add the ebook at
|
||||||
path_to_ebook to the database.
|
path_to_ebook to the database.
|
||||||
''')
|
''')
|
||||||
|
parser.add_option('--with-library', default=None, action='store',
|
||||||
|
help=_('Use the library located at the specified path.'))
|
||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
|
if opts.with_library is not None and os.path.isdir(opts.with_library):
|
||||||
|
prefs.set('library_path', opts.with_library)
|
||||||
|
print 'Using library at', prefs['library_path']
|
||||||
app = Application(args)
|
app = Application(args)
|
||||||
app.setWindowIcon(QIcon(':/library'))
|
app.setWindowIcon(QIcon(':/library'))
|
||||||
QCoreApplication.setOrganizationName(ORG_NAME)
|
QCoreApplication.setOrganizationName(ORG_NAME)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user