raise e
return tmpdir
-def get_publications_html(dirname, category, basename):
+def get_publications(dirname, category, basename):
filename = '{}.bib'.format(category)
if not os.path.exists(filename):
- return None
+ return (None, None)
cmd = ['bibtex2html', '-q', '--no-doc', '--no-header',
filename]
subprocess.check_call(cmd)
with open('{}.html'.format(filename.rsplit('.', 1)[0]), 'r') as f:
html = f.read().split('<hr>')[0].strip().replace('{}_bib.html'.format(category), '{}_bib.html'.format(basename))
- return html
+ with open('{}_bib.html'.format(filename.rsplit('.', 1)[0]), 'r') as f:
+ bib = f.read().split('<hr>')[0].strip().split('\n\n', 2)[2]
+ return (html, bib)
if __name__ == '__main__':
if len(sys.argv) != 2:
categories = ['preprint', 'article', 'book', 'proceeding', 'thesis']
catnames = ['Preprints', 'Zeitschriftenartikel', 'Bücher', 'Proceedings', 'Abschlussarbeiten']
- out = []
- out.append('% use aam ueberschrift="Publikationen"')
+ outhtml = []
+ outbibl = []
+ outhtml.append('% use aam ueberschrift="Publikationen"')
+ outbibl.append('% use aam ueberschrift="BibTeX"')
with tempfile.TemporaryDirectory() as tmpdir:
split_bibtex(tmpdir, filename, categories)
cwd = os.getcwd()
os.chdir(tmpdir)
for (cat, name) in zip(categories, catnames):
- html = get_publications_html(tmpdir, cat, basename)
+ (html, bib) = get_publications(tmpdir, cat, basename)
if html is None:
continue
- out.append('<h2>{}</h2>'.format(name))
- out.append(html)
+ outhtml.append('<h2>{}</h2>'.format(name))
+ outhtml.append(html)
+ outbibl.append(bib)
os.chdir(cwd)
- subprocess.check_call(['bibtex2html', '-q', filename])
with open('{}.html'.format(basename), 'w') as f:
- f.write('\n'.join(out))
+ f.write('\n'.join(outhtml))
+ with open('{}_bib.html'.format(basename), 'w') as f:
+ f.write('\n'.join(outbibl))
print('DONE! Now please copy {}.html and {}_bib.html to the webserver.'.format(basename, basename))