diff --git a/src/calibre/ebooks/lrf/txt/convert_from.py b/src/calibre/ebooks/lrf/txt/convert_from.py
index ff8862a089..89441f9d6d 100644
--- a/src/calibre/ebooks/lrf/txt/convert_from.py
+++ b/src/calibre/ebooks/lrf/txt/convert_from.py
@@ -24,9 +24,9 @@ _('''%prog [options] mybook.txt
dest='debug_html_generation', help=_('Print generated HTML to stdout and quit.'))
return parser
-def fix_image_includes(tdir, match):
+def fix_image_includes(sdir, tdir, match):
path = match.group(1).split('/')
- src = os.path.join(os.getcwd(), *path)
+ src = os.path.join(sdir, *path)
dest = os.path.join(tdir, *path)
p = os.path.dirname(dest)
if not os.path.exists(p):
@@ -64,7 +64,7 @@ def generate_html(txtfile, encoding, tdir):
)
html = '
'+md.convert(txt)+''
for match in re.finditer(r'
]*src="([^"]+)"', html):
- fix_image_includes(tdir, match)
+ fix_image_includes(os.path.dirname(txtfile), tdir, match)
p = os.path.join(tdir, 'index.html')
open(p, 'wb').write(html.encode('utf-8'))
mi = MetaInformation(os.path.splitext(os.path.basename(txtfile))[0], [_('Unknown')])
@@ -109,4 +109,4 @@ def main(args=sys.argv, logger=None):
return 0
if __name__ == '__main__':
- sys.exit(main())
\ No newline at end of file
+ sys.exit(main())
diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py
index c7f6aeb236..949c5c116a 100644
--- a/src/calibre/gui2/main.py
+++ b/src/calibre/gui2/main.py
@@ -1252,7 +1252,12 @@ def main(args=sys.argv):
Launch the main calibre Graphical User Interface and optionally add the ebook at
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)
+ 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.setWindowIcon(QIcon(':/library'))
QCoreApplication.setOrganizationName(ORG_NAME)