aboutsummaryrefslogtreecommitdiffstats
path: root/writeHTML.py
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2013-03-02 00:20:33 +0100
committerNick Mathewson <nickm@torproject.org>2013-03-04 15:43:46 -0500
commit07b87eb5a2001ac3e6a26c307432cf0810cfbd9f (patch)
tree060d224c9edc4607a06cb17049e28c77863dbaa1 /writeHTML.py
parent963913dee0f3ef1926720c0f2fb614affaec7b15 (diff)
downloadanonbib-07b87eb5a2001ac3e6a26c307432cf0810cfbd9f.tar.gz
Also produce a json file of all the bibtex data
Diffstat (limited to 'writeHTML.py')
-rwxr-xr-xwriteHTML.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/writeHTML.py b/writeHTML.py
index d03d76e..19a7c14 100755
--- 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: