diff options
Diffstat (limited to 'writeHTML.py')
| -rwxr-xr-x | writeHTML.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/writeHTML.py b/writeHTML.py index c43da6b..871839a 100755 --- a/writeHTML.py +++ b/writeHTML.py @@ -24,6 +24,7 @@ def getTemplate(name): template_s, template_e = template.split("%(entries)s") return template_s, template_e + def pathLength(s): n = 0 while s: @@ -33,6 +34,7 @@ def pathLength(s): s = parent return n + def writeBody(f, sections, section_urls, cache_path, base_url): '''f: an open file sections: list of (sectionname, [list of BibTeXEntry]) @@ -52,6 +54,7 @@ def writeBody(f, sections, section_urls, cache_path, base_url): print >>f, e.to_html(cache_path=cache_path, base_url=base_url) print >>f, "</ul></li>" + def writeHTML(f, sections, sectionType, fieldName, choices, tag, config, cache_url_path, section_urls={}): """sections: list of (sectionname, [list of BibTeXEntry])''' @@ -107,10 +110,11 @@ def writeHTML(f, sections, sectionType, fieldName, choices, } header, footer = getTemplate(config.TEMPLATE_FILE) - print >>f, header%fields + print >>f, header % fields writeBody(f, sections, section_urls, cache_path=cache_url_path, base_url=root) - print >>f, footer%fields + print >>f, footer % fields + def jsonDumper(obj): if isinstance(obj, BibTeX.BibTeXEntry): @@ -118,17 +122,18 @@ def jsonDumper(obj): e['key'] = obj.key return e else: - raise TypeError("Do not know how to serialize %s"%(obj.__class,)) + 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.values() + bib_entries = [ b for b in bib if tag in b.get('www_tags', "").split() ] else: - bib_entries = bib.entries.copy().values() + bib_entries = bib.entries.values()[:] if not bib_entries: - print >>sys.stderr, "No entries with tag %r; skipping"%tag + print >>sys.stderr, "No entries with tag %r; skipping" % tag return tagdir = config.TAG_DIRECTORIES[tag] |
