Skip to content

Commit a0ee11c

Browse files
committed
FIX: Always propagate existing Zenodo authors
1 parent 50952d7 commit a0ee11c

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

tools/update_zenodo.py

+11-29
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,8 @@
77
from fuzzywuzzy import fuzz, process
88
import subprocess as sp
99

10-
# These ORCIDs should go last
10+
# These names should go last
1111
CREATORS_LAST = ['Gorgolewski, Krzysztof J.', 'Ghosh, Satrajit']
12-
# for entries not found in line-contributions
13-
MISSING_ENTRIES = [
14-
{"name": "Varada, Jan"},
15-
{"name": "Schwabacher, Isaac"},
16-
{"affiliation": "Child Mind Institute / Nathan Kline Institute",
17-
"name": "Pellman, John",
18-
"orcid": "0000-0001-6810-4461"},
19-
{"name": "Khanuja, Ranjeet"},
20-
{"affiliation":
21-
"Medical Imaging & Biomarkers, Bioclinica, Newark, CA, USA.",
22-
"name": "Pannetier, Nicolas",
23-
"orcid": "0000-0002-0744-5155"},
24-
{"name": "McDermottroe, Conor"},
25-
{"affiliation":
26-
"Max Planck Institute for Human Cognitive and Brain Sciences, "
27-
"Leipzig, Germany.",
28-
"name": "Mihai, Paul Glad",
29-
"orcid": "0000-0001-5715-6442"},
30-
{"name": "Lai, Jeff"}
31-
]
3212

3313
if __name__ == '__main__':
3414
contrib_file = Path('line-contributors.txt')
@@ -55,21 +35,22 @@
5535
zenodo = json.loads(zenodo_file.read_text())
5636
zen_names = [' '.join(val['name'].split(',')[::-1]).strip()
5737
for val in zenodo['creators']]
58-
total_names = len(zen_names) + len(MISSING_ENTRIES)
38+
total_names = len(zen_names)
5939

6040
name_matches = []
6141
position = 1
6242
for ele in data:
6343
matches = process.extract(ele, zen_names, scorer=fuzz.token_sort_ratio,
6444
limit=2)
6545
# matches is a list [('First match', % Match), ('Second match', % Match)]
66-
if matches[0][1] > 80:
67-
val = zenodo['creators'][zen_names.index(matches[0][0])]
68-
else:
46+
if matches[0][1] <= 80:
6947
# skip unmatched names
7048
print("No entry to sort:", ele)
7149
continue
7250

51+
idx = zen_names.index(matches[0][0])
52+
val = zenodo['creators'][idx]
53+
7354
if val not in name_matches:
7455
if val['name'] not in CREATORS_LAST:
7556
val['position'] = position
@@ -78,10 +59,11 @@
7859
val['position'] = total_names + CREATORS_LAST.index(val['name'])
7960
name_matches.append(val)
8061

81-
for missing in MISSING_ENTRIES:
82-
missing['position'] = position
83-
position += 1
84-
name_matches.append(missing)
62+
for missing in zenodo['creators']:
63+
if 'position' not in missing:
64+
missing['position'] = position
65+
position += 1
66+
name_matches.append(missing)
8567

8668
zenodo['creators'] = sorted(name_matches, key=lambda k: k['position'])
8769
# Remove position

0 commit comments

Comments
 (0)