Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f079ed2

Browse files
committed
ENH: Add zenodo updating script
1 parent a6d1d6e commit f079ed2

File tree

2 files changed

+96
-11
lines changed

2 files changed

+96
-11
lines changed

‎.zenodo.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,6 @@
468468
{
469469
"name": "Cheung, Brian"
470470
},
471-
{
472-
"affiliation": "The University of Texas at Austin",
473-
"name": "Floren, Andrew",
474-
"orcid": "0000-0003-3618-2056"
475-
},
476471
{
477472
"name": "Urchs, Sebastian"
478473
},
@@ -487,14 +482,19 @@
487482
"orcid": "0000-0003-2076-5329"
488483
},
489484
{
490-
"affiliation": "University of illinois urbana champaign",
491-
"name": "Sharp, Paul"
485+
"affiliation": "The University of Texas at Austin",
486+
"name": "Floren, Andrew",
487+
"orcid": "0000-0003-3618-2056"
492488
},
493489
{
494490
"affiliation": "Institute of Neuroinformatics, ETH/University of Zurich",
495491
"name": "Gerhard, Stephan",
496492
"orcid": "0000-0003-4454-6171"
497493
},
494+
{
495+
"affiliation": "University of Illinois Urbana Champaign",
496+
"name": "Sharp, Paul"
497+
},
498498
{
499499
"affiliation": "Technical University Munich",
500500
"name": "Molina-Romero, Miguel",
@@ -545,10 +545,6 @@
545545
{
546546
"name": "Tarbert, Claire"
547547
},
548-
{
549-
"affiliation": "Vrije Universiteit Amsterdam",
550-
"name": "Ort, Eduard"
551-
},
552548
{
553549
"name": "Nickson, Thomas"
554550
},
@@ -569,6 +565,10 @@
569565
{
570566
"name": "Flandin, Guillaume"
571567
},
568+
{
569+
"affiliation": "Vrije Universiteit Amsterdam",
570+
"name": "Ort, Eduard"
571+
},
572572
{
573573
"name": "Shachnev, Dmitry"
574574
},

‎tools/update_zenodo.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python3
2+
import json
3+
from fuzzywuzzy import fuzz, process
4+
import shutil
5+
import os
6+
import subprocess as sp
7+
8+
if os.path.exists('line-contributions.txt'):
9+
with open('line-contributions.txt', 'rt') as fp:
10+
lines = fp.readlines()
11+
else:
12+
if shutil.which('git-line-summary'):
13+
print("Running git-line-summary on nipype repo")
14+
lines = sp.check_output(['git-line-summary']).decode().split('\n')
15+
else:
16+
raise RuntimeError("Install Git Extras to view git contributors")
17+
18+
data = [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]
19+
20+
# load zenodo from master
21+
with open('.zenodo.json', 'rt') as fp:
22+
zenodo = json.load(fp)
23+
zen_names = [' '.join(val['name'].split(',')[::-1]).strip()
24+
for val in zenodo['creators']]
25+
26+
name_matches = []
27+
28+
for ele in data:
29+
matches = process.extract(ele, zen_names, scorer=fuzz.token_sort_ratio,
30+
limit=2)
31+
# matches is a list [('First match', % Match), ('Second match', % Match)]
32+
if matches[0][1] > 80:
33+
val = zenodo['creators'][zen_names.index(matches[0][0])]
34+
else:
35+
# skip unmatched names
36+
print("No entry to sort:", ele)
37+
continue
38+
39+
if val not in name_matches:
40+
name_matches.append(val)
41+
42+
# for entries not found in line-contributions
43+
missing_entries = [
44+
{"name": "Varada, Jan"},
45+
{"name": "Schwabacher, Isaac"},
46+
{"affiliation": "Child Mind Institute / Nathan Kline Institute",
47+
"name": "Pellman, John",
48+
"orcid": "0000-0001-6810-4461"},
49+
{"name": "Perez-Guevara, Martin"},
50+
{"name": "Khanuja, Ranjeet"},
51+
{"affiliation":
52+
"Medical Imaging & Biomarkers, Bioclinica, Newark, CA, USA.",
53+
"name": "Pannetier, Nicolas",
54+
"orcid": "0000-0002-0744-5155"},
55+
{"name": "McDermottroe, Conor"},
56+
]
57+
58+
for entry in missing_entries:
59+
name_matches.append(entry)
60+
61+
62+
def fix_position(creators):
63+
# position first / last authors
64+
f_authr = None
65+
l_authr = None
66+
67+
for i, info in enumerate(creators):
68+
if info['name'] == 'Gorgolewski, Krzysztof J.':
69+
f_authr = i
70+
if info['name'] == 'Ghosh, Satrajit':
71+
l_authr = i
72+
73+
if f_authr is None or l_authr is None:
74+
raise AttributeError('Missing important people')
75+
76+
creators.insert(0, creators.pop(f_authr))
77+
creators.insert(len(creators), creators.pop(l_authr + 1))
78+
return creators
79+
80+
81+
zenodo['creators'] = fix_position(name_matches)
82+
83+
with open('.zenodo.json', 'wt') as fp:
84+
json.dump(zenodo, fp, indent=2, sort_keys=True)
85+
fp.write('\n')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /