Skip to content

Commit

Permalink
[codemeta] Include authors and contributors.
Browse files Browse the repository at this point in the history
  • Loading branch information
kresan committed Oct 4, 2021
1 parent 1580116 commit de3c099
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 36 deletions.
226 changes: 190 additions & 36 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,192 @@
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"license": "https://spdx.org/licenses/GPL-3.0",
"codeRepository": "git+https://github.com/R3BRootGroup/R3BRoot.git",
"contIntegration": "https://github.com/R3BRootGroup/R3BRoot/actions",
"dateCreated": "2009-04-14",
"datePublished": "2009-08-01",
"dateModified": "2021-05-12",
"downloadUrl": "https://github.com/R3BRootGroup/R3BRoot/archive/refs/tags/may21.tar.gz",
"issueTracker": "https://github.com/R3BRootGroup/R3BRoot/issues",
"name": "R3BRoot",
"version": "may21",
"description": "Software for simulations and data analysis of Reactions with Relativistic Radioactive Beams experiment at FAIR",
"applicationCategory": "Nuclear physics",
"developmentStatus": "active",
"referencePublication": "https://doi.org/10.1088/1742-6596/523/1/012034",
"keywords": [
"MC simulation",
"structure of nuclei",
"nuclear reactions",
"excitation energy"
],
"programmingLanguage": [
"C",
"C++"
],
"runtimePlatform": [
"ROOT"
],
"operatingSystem": [
"Linux",
"macOS"
],
"softwareRequirements": [
"FairRoot, FairSoft"
]
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"license": "https://spdx.org/licenses/GPL-3.0",
"codeRepository": "git+https://github.com/R3BRootGroup/R3BRoot.git",
"contIntegration": "https://github.com/R3BRootGroup/R3BRoot/actions",
"dateCreated": "2009-04-14",
"datePublished": "2009-08-01",
"dateModified": "2021-05-12",
"downloadUrl": "https://github.com/R3BRootGroup/R3BRoot/archive/refs/tags/may21.tar.gz",
"issueTracker": "https://github.com/R3BRootGroup/R3BRoot/issues",
"name": "R3BRoot",
"version": "may21",
"description": "Software for simulations and data analysis of Reactions with Relativistic Radioactive Beams experiment at FAIR",
"applicationCategory": "Nuclear physics",
"developmentStatus": "active",
"referencePublication": "https://doi.org/10.1088/1742-6596/523/1/012034",
"keywords": [
"MC simulation",
"structure of nuclei",
"nuclear reactions",
"excitation energy"
],
"programmingLanguage": [
"C",
"C++"
],
"runtimePlatform": [
"ROOT"
],
"operatingSystem": [
"Linux",
"macOS"
],
"softwareRequirements": [
"FairRoot, FairSoft"
],
"author": [
{
"@type": "Person",
"givenName": "Hector",
"familyName": "Alvarez Pol"
},
{
"@type": "Person",
"givenName": "Michael",
"familyName": "Heil"
},
{
"@type": "Person",
"givenName": "Dmytro",
"familyName": "Kresan"
},
{
"@type": "Person",
"givenName": "Jan",
"familyName": "Mayer"
},
{
"@type": "Person",
"givenName": "Jose Luis",
"familyName": "Rodriguez"
},
{
"@type": "Person",
"givenName": "Vadim",
"familyName": "Wagner"
}
],
"contributor": [
{
"@type": "Person",
"givenName": "Pablo",
"familyName": "Cabanelas"
},
{
"@type": "Person",
"givenName": "Audrey",
"familyName": "Chatillon"
},
{
"@type": "Person",
"givenName": "Christiaan",
"familyName": "Douma"
},
{
"@type": "Person",
"givenName": "Ashton",
"familyName": "Falduto"
},
{
"@type": "Person",
"givenName": "Eli",
"familyName": "Galiana"
},
{
"@type": "Person",
"givenName": "Gabriel",
"familyName": "Garcia"
},
{
"@type": "Person",
"givenName": "Igor",
"familyName": "Gasparic"
},
{
"@type": "Person",
"givenName": "Antia",
"familyName": "Gra\u00f1a"
},
{
"@type": "Person",
"givenName": "Benjamin",
"familyName": "Heiss"
},
{
"@type": "Person",
"givenName": "Alexander",
"familyName": "Inglessi"
},
{
"@type": "Person",
"givenName": "Aleksandra",
"familyName": "Kelic-Heil"
},
{
"@type": "Person",
"givenName": "Philipp",
"familyName": "Klenze"
},
{
"@type": "Person",
"givenName": "Aron",
"familyName": "Kripko"
},
{
"@type": "Person",
"givenName": "Marc",
"familyName": "Labiche"
},
{
"@type": "Person",
"givenName": "Bastian",
"familyName": "Loeher"
},
{
"@type": "Person",
"givenName": "Ralf",
"familyName": "Plag"
},
{
"@type": "Person",
"givenName": "Lukas",
"familyName": "Ponnath"
},
{
"@type": "Person",
"givenName": "Alexey",
"familyName": "Rybalchenko"
},
{
"@type": "Person",
"givenName": "Sonja",
"familyName": "Storck"
},
{
"@type": "Person",
"givenName": "Ina",
"familyName": "Syndikus"
},
{
"@type": "Person",
"givenName": "Ryo",
"familyName": "Taniuchi"
},
{
"@type": "Person",
"givenName": "Joachim",
"familyName": "Tscheuschner"
},
{
"@type": "Person",
"givenName": "Alicia",
"familyName": "Wongel"
},
{
"@type": "Person",
"givenName": "Lorenzo",
"familyName": "Zanetti"
}
]
}
83 changes: 83 additions & 0 deletions codemeta_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#! /usr/bin/env python3
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
#
# SPDX-License-Identifier: LGPL-3.0-or-later


import argparse
import json
import re
from collections import OrderedDict


class CodeMetaManipulator(object):
def load(self, filename='codemeta.json'):
with open(filename, 'rb') as fp:
self.data = json.load(fp, object_pairs_hook=OrderedDict)

@staticmethod
def _dict_entry_cmp(dict1, dict2, field):
if (field in dict1) and (field in dict2):
return dict1[field] == dict2[field]
else:
return False

@classmethod
def find_person_entry(cls, person_list, matchdict):
for entry in person_list:
if cls._dict_entry_cmp(entry, matchdict, 'email'):
return entry
if cls._dict_entry_cmp(entry, matchdict, 'familyName') \
and cls._dict_entry_cmp(entry, matchdict, 'givenName'):
return entry
return None

@staticmethod
def update_person_entry(entry, matchdict):
if entry is None:
entry = OrderedDict()
entry['@type'] = 'Person'
for field in ('givenName', 'familyName', 'email'):
val = matchdict.get(field, None)
if val is not None:
entry[field] = val
return entry

def handle_person_list_file(self, filename, cm_field_name):
fp = open(filename, 'r', encoding='utf8')
findregex = re.compile(r'^(?P<familyName>[-\w\s]*[-\w]),\s*'
r'(?P<givenName>[-\w\s]*[-\w])\s*'
r'(?:<(?P<email>\S+@\S+)>)?$')
person_list = self.data.setdefault(cm_field_name, [])
for line in fp:
line = line.strip()
m = findregex.match(line)
if m is None:
raise RuntimeError("Could not analyze line %r" % line)
found_entry = self.find_person_entry(person_list, m.groupdict())
entry = self.update_person_entry(found_entry, m.groupdict())
if found_entry is None:
person_list.append(entry)

def save(self, filename='codemeta.json'):
with open('codemeta.json', 'w', encoding='utf8') as fp:
json.dump(self.data, fp, indent=2)
fp.write('\n')


def main():
parser = argparse.ArgumentParser(description='Update codemeta.json')
parser.add_argument('--set-version', dest='newversion')
args = parser.parse_args()

cm = CodeMetaManipulator()
cm.load()
if args.newversion is not None:
cm.data['softwareVersion'] = args.newversion
cm.handle_person_list_file('AUTHORS', 'author')
cm.handle_person_list_file('CONTRIBUTORS', 'contributor')
cm.save()


if __name__ == '__main__':
main()

0 comments on commit de3c099

Please sign in to comment.