[GRASS-SVN] r72874 - sandbox/wenzeslaus/g.citation
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 21 19:02:55 PDT 2018
Author: wenzeslaus
Date: 2018-06-21 19:02:54 -0700 (Thu, 21 Jun 2018)
New Revision: 72874
Modified:
sandbox/wenzeslaus/g.citation/g.citation.py
Log:
g.citation: support optional entries using defaultdict
Modified: sandbox/wenzeslaus/g.citation/g.citation.py
===================================================================
--- sandbox/wenzeslaus/g.citation/g.citation.py 2018-06-22 01:49:33 UTC (rev 72873)
+++ sandbox/wenzeslaus/g.citation/g.citation.py 2018-06-22 02:02:54 UTC (rev 72874)
@@ -79,7 +79,7 @@
import sys
import os
import re
-
+from collections import defaultdict
from pprint import pprint
import grass.script as gs
@@ -259,6 +259,8 @@
given, family = author['name'].split(" ", 1)
print(" - family-names:", family)
print(" given-names:", given)
+ if author['orcid']:
+ print(" orcid:", author['orcid'])
print("title: \"GRASS GIS: ", citation['module'], " module\"", sep="")
print("version:", "TODO")
# CFF 1.0.3 does not say expplicitely except for Date (so not any
@@ -269,6 +271,10 @@
# license string according to https://spdx.org/licenses/
# we know license of GRASS modules should be GPL>=2
print("license: GPL-2.0-or-later")
+ if citation['keywords']:
+ print("keywords:")
+ for keyword in citation['keywords']:
+ print(" -", keyword)
def print_bibtex(citation):
@@ -343,7 +349,9 @@
text = open(path).read()
- citation = {}
+ # using default empty value, this way we use just if d['k']
+ # to check presence and non-emptiness at the same time
+ citation = defaultdict(str)
citation['module'] = name
citation['authors'] = get_authors_from_documentation(text)
citation['year'] = get_year_from_documentation(text)
More information about the grass-commit
mailing list