Skip to content

Commit

Permalink
added --with-orcid parameter to generate @id placeholder fields with …
Browse files Browse the repository at this point in the history
…ORCIDs (to be manually complemented) #2
  • Loading branch information
proycon committed Aug 30, 2018
1 parent c0eb385 commit c5043e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions codemeta/codemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def readcrosswalk(sourcekeys=(CWKey.PYPI,)):
return props, mapping


def parsepip(data, lines, mapping=None, with_entrypoints=False):
def parsepip(data, lines, mapping=None, with_entrypoints=False, orcid_placeholder=False):
"""Parses pip -v output and converts to codemeta"""
if mapping is None:
_, mapping = readcrosswalk((CWKey.PYPI,))
Expand Down Expand Up @@ -136,6 +136,8 @@ def parsepip(data, lines, mapping=None, with_entrypoints=False):
if key == "Author":
humanname = HumanName(value.strip())
data["author"].append({"@type":"Person", "givenName": humanname.first, "familyName": " ".join((humanname.middle, humanname.last)).strip() })
if orcid_placeholder:
data["author"][-1]["@id"] = "https://orcid.org/EDIT_ME!"
elif key == "Author-email":
data["author"][-1]["email"] = value
elif key == "Requires":
Expand Down Expand Up @@ -237,6 +239,7 @@ def main():
#parser.add_argument('--pip', help="Parse pip -v output", action='store_true',required=False)
#parser.add_argument('--yaml', help="Read metadata from standard input (YAML format)", action='store_true',required=False)
parser.add_argument('-e','--with-entrypoints', dest="with_entrypoints", help="Add entry points (this is not in the official codemeta specification)", action='store_true',required=False)
parser.add_argument('--with-orcid', dest="with_orcid", help="Add placeholders for ORCID, requires manual editing of the output to insert the actual ORCIDs", action='store_true',required=False)
parser.add_argument('-o', dest='output',type=str,help="Metadata output type: json (default), yaml", action='store',required=False, default="json")
parser.add_argument('-i', dest='input',type=str,help="Metadata input type: pip (default), registry, json, yaml. May be a comma seperated list of multiple types if files are passed on the command line", action='store',required=False, default="pip")
parser.add_argument('-r', dest='registry',type=str,help="The given registry file groups multiple JSON-LD metadata together in one JSON file. If specified, the file will be read (or created), and updated. This is a custom extension not part of the CodeMeta specification", action='store',required=False)
Expand Down Expand Up @@ -293,7 +296,7 @@ def main():
update(data, getregistry(stream, registry))
elif inputtype == "pip":
piplines = stream.read().split("\n")
update(data, parsepip(data, piplines, mapping, args.with_entrypoints))
update(data, parsepip(data, piplines, mapping, args.with_entrypoints, args.with_orcid))
elif inputtype == "json":
update(data, json.load(stream))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def read(fname):

setup(
name = "CodeMetaPy",
version = "0.1.4",
version = "0.1.5",
author = "Maarten van Gompel",
author_email = "[email protected]",
description = ("Generate CodeMeta metadata for Python packages"),
Expand Down

0 comments on commit c5043e2

Please sign in to comment.