aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BibTeX.py21
-rw-r--r--config.py3
2 files changed, 18 insertions, 6 deletions
diff --git a/BibTeX.py b/BibTeX.py
index 110e5ff..e076200 100644
--- a/BibTeX.py
+++ b/BibTeX.py
@@ -10,6 +10,7 @@ import cStringIO
import re
import sys
import os
+import copy
import config
@@ -160,10 +161,15 @@ def splitEntriesBy(entries, field):
result = {}
for ent in entries:
key = ent.get(field)
- try:
- result[key].append(ent)
- except:
- result[key] = [ent]
+ if field in config.MULTI_VAL_FIELDS:
+ key = [k.strip() for k in key.split(',')]
+ else:
+ key = [key]
+ for k in key:
+ try:
+ result[k].append(ent)
+ except:
+ result[k] = [ent]
return result
def splitSortedEntriesBy(entries, field):
@@ -195,7 +201,12 @@ def sortEntriesBy(entries, field, default):
v = ent.get(field, default)
if v.startswith("<span class='bad'>"):
v = default
- tmp.append((txtize(v), i, ent))
+ if field in config.MULTI_VAL_FIELDS:
+ for v_j in v.split(','):
+ ent_j = copy.deepcopy(ent)
+ ent_j.__setitem__(field, v_j.strip())
+ tmp.append((txtize(v_j.strip()), i, ent_j))
+ else: tmp.append((txtize(v), i, ent))
tmp.sort()
return [ t[2] for t in tmp ]
diff --git a/config.py b/config.py
index c1b1b6e..f6acdef 100644
--- a/config.py
+++ b/config.py
@@ -10,7 +10,7 @@ _KEYS = [ "ALL_TAGS",
"DOWNLOAD_CONNECT_TIMEOUT","INITIAL_STRINGS",
"MASTER_BIB", "NO_COLLAPSE_AUTHORS", "OMIT_ENTRIES",
"OUTPUT_DIR", "TEMPLATE_FILE", "BIBTEX_TEMPLATE_FILE",
- "REQUIRE_KEY", "TAG_TITLES", "TAG_DIRECTORIES", "TAG_SHORT_TITLES",
+ "REQUIRE_KEY", "TAG_TITLES", "TAG_DIRECTORIES", "TAG_SHORT_TITLES", "MULTI_VAL_FIELDS"
]
for _k in _KEYS:
@@ -54,3 +54,4 @@ AUTHOR_RE_LIST = []
NO_COLLAPSE_AUTHORS_RE_LIST = []
ALPHABETIZE_AUTHOR_AS_RE_LIST = []
+