gnunetbib

Bibliography (BibTeX, based on AnonBib)
Log | Files | Refs | README | LICENSE

commit b7e80caf685c072b2e24a2231ef99656c47d85dd
parent 9cec617fb9d1bd1fab90d88bfeacdd36f4979880
Author: Peter Palfrader <peter@palfrader.org>
Date:   Sat,  2 Mar 2013 00:20:33 +0100

Also produce a json file of all the bibtex data

Diffstat:
MwriteHTML.py | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/writeHTML.py b/writeHTML.py @@ -6,6 +6,7 @@ import sys import re import os +import json assert sys.version_info[:3] >= (2,2,0) os.umask(022) @@ -108,6 +109,14 @@ def writeHTML(f, sections, sectionType, fieldName, choices, base_url=root) print >>f, footer%fields +def jsonDumper(obj): + if isinstance(obj, BibTeX.BibTeXEntry): + e = obj.entries.copy() + e['key'] = obj.key + return e + else: + raise TypeError("Do not know how to serialize %s"%(obj.__class,)) + def writePageSet(config, bib, tag): if tag: bib_entries = [ b for b in bib.entries @@ -218,6 +227,10 @@ def writePageSet(config, bib, tag): print >>f, footer f.close() + f = open(os.path.join(outdir,"bibtex.json"), 'w') + json.dump(entries, f, default=jsonDumper) + f.close() + if __name__ == '__main__': if len(sys.argv) == 2: