if not flags or not 'without-fonts' in flags:
# strip fonts
tmpdir = mkdtemp('-librarian-epub')
- cwd = os.getcwd()
+ try:
+ cwd = os.getcwd()
+ except OSError:
+ cwd = None
os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'font-optimizer'))
for fname in 'DejaVuSerif.ttf', 'DejaVuSerif-Bold.ttf', 'DejaVuSerif-Italic.ttf', 'DejaVuSerif-BoldItalic.ttf':
manifest.append(etree.fromstring(
'<item id="%s" href="%s" media-type="font/ttf" />' % (fname, fname)))
rmtree(tmpdir)
- os.chdir(cwd)
+ if cwd is not None:
+ os.chdir(cwd)
zip.writestr('OPS/content.opf', etree.tostring(opf, pretty_print=True))
title = document.book_info.title
shutil.copy(get_resource('pdf/wl.cls'), temp)
shutil.copy(get_resource('res/wl-logo.png'), temp)
- cwd = os.getcwd()
+ try:
+ cwd = os.getcwd()
+ except OSError:
+ cwd = None
os.chdir(temp)
if verbose:
if p:
raise ParseError("Error parsing .tex file")
- os.chdir(cwd)
+ if cwd is not None:
+ os.chdir(cwd)
output_file = NamedTemporaryFile(prefix='librarian', suffix='.pdf', delete=False)
pdf_path = os.path.join(temp, 'doc.pdf')