From 0617a86ad09a502a9805d5b4073591bc1ad4a337 Mon Sep 17 00:00:00 2001 From: str4d Date: Mon, 12 Aug 2013 06:26:48 -0500 Subject: Don't fail if one of the hardcoded negative indexes does not exist This fixes the corner case where a tag set includes one year or less - the list would not have an entry at index -2 (or -1 if no papers have the tag). --- writeHTML.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/writeHTML.py b/writeHTML.py index 19a7c14..2a3d455 100755 --- a/writeHTML.py +++ b/writeHTML.py @@ -162,10 +162,13 @@ def writePageSet(config, bib, tag): entries = BibTeX.sortEntriesByDate(bib_entries) entries = BibTeX.splitSortedEntriesBy(entries, 'year') for idx in -1, -2: - if entries[idx][0].startswith(""): - entries[idx] = ("Unknown", entries[idx][1]) - elif entries[idx][0].startswith("forthcoming"): - entries[idx] = ("Forthcoming", entries[idx][1]) + try: + if entries[idx][0].startswith(""): + entries[idx] = ("Unknown", entries[idx][1]) + elif entries[idx][0].startswith("forthcoming"): + entries[idx] = ("Forthcoming", entries[idx][1]) + except IndexError: + continue sections = [ ent[0] for ent in entries ] first_year = int(entries[0][1][0]['year']) -- cgit v1.2.3-70-g09d2