diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2016-02-04 20:00:45 -0500 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2016-02-04 20:00:45 -0500 |
| commit | da7359cd452f2ded9e05e753fb125508343b8587 (patch) | |
| tree | fab5a9cd876a52bf378ff19441c3224d72e9c1d3 /writeHTML.py | |
| parent | c25f5fefbfdcbee15685778dcf25b82849e0d617 (diff) | |
| download | anonbib-da7359cd452f2ded9e05e753fb125508343b8587.tar.gz | |
Split sort utilities
Diffstat (limited to 'writeHTML.py')
| -rwxr-xr-x | writeHTML.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/writeHTML.py b/writeHTML.py index 2a3d455..d4e11a0 100755 --- a/writeHTML.py +++ b/writeHTML.py @@ -12,6 +12,10 @@ assert sys.version_info[:3] >= (2,2,0) os.umask(022) import BibTeX +from sortutils import sortEntriesBy, splitSortedEntriesBy, sortEntriesByDate,\ + splitEntriesByAuthor +from utils import smartJoin, url_untranslate +from entry import buildAuthorTable import config def getTemplate(name): @@ -40,10 +44,10 @@ def writeBody(f, sections, section_urls, cache_path, base_url): sDisp = sDisp.replace(" ", " ") if u: print >>f, ('<li><h3><a name="%s"></a><a href="%s">%s</a></h3>'%( - (BibTeX.url_untranslate(s), u, sDisp))) + (url_untranslate(s), u, sDisp))) else: print >>f, ('<li><h3><a name="%s">%s</a></h3>'%( - BibTeX.url_untranslate(s),sDisp)) + url_untranslate(s),sDisp)) print >>f, "<ul class='expand'>" for e in entries: print >>f, e.to_html(cache_path=cache_path, base_url=base_url) @@ -64,7 +68,7 @@ def writeHTML(f, sections, sectionType, fieldName, choices, hts = re.sub(r'\s+', ' ', s.strip()) hts = s.replace(" ", " ") secStr.append("<p class='l2'><a href='#%s'>%s</a></p>\n"% - ((BibTeX.url_untranslate(s),hts))) + ((url_untranslate(s),hts))) secStr = "".join(secStr) # @@ -78,7 +82,7 @@ def writeHTML(f, sections, sectionType, fieldName, choices, if t == tag: tagListStr.append(name) else: - url = BibTeX.smartJoin(root, config.TAG_DIRECTORIES[t], "date.html") + url = smartJoin(root, config.TAG_DIRECTORIES[t], "date.html") tagListStr.append("<a href='%s'>%s</a>"%(url, name)) tagListStr = " | ".join(tagListStr) @@ -130,7 +134,7 @@ def writePageSet(config, bib, tag): tagdir = config.TAG_DIRECTORIES[tag] outdir = os.path.join(config.OUTPUT_DIR, tagdir) - cache_url_path = BibTeX.smartJoin("../"*pathLength(tagdir), + cache_url_path = smartJoin("../"*pathLength(tagdir), config.CACHE_DIR) if not os.path.exists(outdir): os.makedirs(outdir, 0755) @@ -138,12 +142,12 @@ def writePageSet(config, bib, tag): ## By topic. - entries = BibTeX.sortEntriesBy(bib_entries, "www_section", "ZZZZZZZZZZZZZZ") - entries = BibTeX.splitSortedEntriesBy(entries, "www_section") + entries = sortEntriesBy(bib_entries, "www_section", "ZZZZZZZZZZZZZZ") + entries = splitSortedEntriesBy(entries, "www_section") if entries[-1][0].startswith("<span class='bad'>"): entries[-1] = ("Miscellaneous", entries[-1][1]) - entries = [ (s, BibTeX.sortEntriesByDate(ents)) + entries = [ (s, sortEntriesByDate(ents)) for s, ents in entries ] @@ -159,8 +163,8 @@ def writePageSet(config, bib, tag): ## By date. - entries = BibTeX.sortEntriesByDate(bib_entries) - entries = BibTeX.splitSortedEntriesBy(entries, 'year') + entries = sortEntriesByDate(bib_entries) + entries = splitSortedEntriesBy(entries, 'year') for idx in -1, -2: try: if entries[idx][0].startswith("<span class='bad'>"): @@ -192,7 +196,7 @@ def writePageSet(config, bib, tag): f.close() ## By author - entries, url_map = BibTeX.splitEntriesByAuthor(bib_entries) + entries, url_map = splitEntriesByAuthor(bib_entries) f = open(os.path.join(outdir,"author.html"), 'w') writeHTML(f, entries, "Authors", "author", @@ -226,7 +230,7 @@ def writePageSet(config, bib, tag): print >>f, ( ("<tr><td class='bibtex'><a name='%s'>%s</a>" "<pre class='bibtex'>%s</pre></td></tr>") - %(BibTeX.url_untranslate(ent.key), ent.key, ent.format(90,8,1))) + %(url_untranslate(ent.key), ent.key, ent.format(90,8,1))) print >>f, footer f.close() |
