diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2016-09-09 19:57:14 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2016-09-09 19:57:14 +0200 |
commit | 9f93adb02efbfca88de57f8fe2a96184ed37ecca (patch) | |
tree | 42dd2c15b97149c78b65a4b4673f43931aa1e350 | |
parent | 2f4770dbd83d74774e11fa5f4fc8e832158e7e2f (diff) | |
download | eumel-9f93adb02efbfca88de57f8fe2a96184ed37ecca.tar.gz eumel-9f93adb02efbfca88de57f8fe2a96184ed37ecca.tar.bz2 eumel-9f93adb02efbfca88de57f8fe2a96184ed37ecca.zip |
bibliography: Show page numbers
-rwxr-xr-x | formatRefs.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/formatRefs.py b/formatRefs.py index 4da52c6..e17aac2 100755 --- a/formatRefs.py +++ b/formatRefs.py @@ -34,12 +34,13 @@ def formatPerson (s, g, n): else: return familyname -def formatParent (s, g, n): +def formatParent (s, g, n, useName = True): ret = [] - parentname = first (g.objects (n, s.name)) - if parentname: - ret.append (parentname) + if useName: + parentname = first (g.objects (n, s.name)) + if parentname: + ret.append (parentname) volume = first (g.objects (n, s.volumeNumber)) if volume: @@ -49,6 +50,16 @@ def formatParent (s, g, n): if issue: ret.append ('issue {}'.format (issue)) + # pages + start = first (g.objects (n, s.pageStart)) + end = first (g.objects (n, s.pageEnd)) + if start: + num = int (end)-int (start) + if end and num > 1: + ret.append ('pp. {}–{}'.format (start, end)) + else: + ret.append ('p. {}'.format (start)) + return ', '.join (ret) def relUri (base, u): @@ -108,7 +119,10 @@ if __name__ == '__main__': # where can we find it? (print) # print from root to ref (i.e. magazine, volume, issue) parents = reversed (list (getRecursiveAll (s, g, ref, s.isPartOf))) - where = [formatParent (s, g, p) for p in parents] + where = [formatParent (s, g, p) for p in parents] + thiswhere = formatParent (s, g, ref, False) + if thiswhere: + where.append (thiswhere) # where can we find it? (online) urls = hideLocalUri (rootUri, g.objects (ref, s.url)) |