Skip to content

Commit ee9f633

Browse files
committedMar 22, 2021
Blacken generate_metadata script
1 parent 0b713d6 commit ee9f633

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed
 

‎paper/generate_metadata.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,47 @@
1111
here = Path.cwd()
1212

1313
with (here.parent / "codemeta.json").open() as fp:
14-
cm = load(fp)
14+
cm = load(fp)
1515

1616

1717
# print(cm)
1818

1919

2020
def ordered_set(iterable):
21-
return OrderedDict.fromkeys(iterable).keys()
21+
return OrderedDict.fromkeys(iterable).keys()
2222

2323

2424
uniq_affiliations = list(ordered_set(author["affiliation"] for author in cm["author"]))
2525

2626

2727
def make_author(author):
28-
data = {
29-
"name": " ".join([author["givenName"], author["familyName"]]),
30-
"affiliation": uniq_affiliations.index(author.get("affiliation", "")) + 1,
31-
}
32-
orcid_url = author.get("@id")
33-
if orcid_url:
34-
data.update({"orcid": Path(orcid_url).name})
35-
return data
28+
data = {
29+
"name": " ".join([author["givenName"], author["familyName"]]),
30+
"affiliation": uniq_affiliations.index(author.get("affiliation", "")) + 1,
31+
}
32+
orcid_url = author.get("@id")
33+
if orcid_url:
34+
data.update({"orcid": Path(orcid_url).name})
35+
return data
3636

3737

3838
def make_affiliations():
39-
return [{"name": name, "index": i+1} for i, name in enumerate(uniq_affiliations)]
39+
return [{"name": name, "index": i + 1} for i, name in enumerate(uniq_affiliations)]
4040

4141

4242
def make_date(date):
43-
date_parsed = datetime.strptime(date, "%Y-%m-%d")
44-
return datetime.strftime(date_parsed, "%d %B %Y")
43+
date_parsed = datetime.strptime(date, "%Y-%m-%d")
44+
return datetime.strftime(date_parsed, "%d %B %Y")
4545

4646

4747
# Prepare data for metadata output
4848
data = {
49-
"title": cm.get("title", ""),
50-
"tags": cm.get("keywords", []),
51-
"authors": [make_author(_) for _ in cm.get("author", [{}])],
52-
"affiliations": make_affiliations(),
53-
"date": make_date(cm.get("dateModified", "")),
54-
"bibliography": "paper.bib",
49+
"title": cm.get("title", ""),
50+
"tags": cm.get("keywords", []),
51+
"authors": [make_author(_) for _ in cm.get("author", [{}])],
52+
"affiliations": make_affiliations(),
53+
"date": make_date(cm.get("dateModified", "")),
54+
"bibliography": "paper.bib",
5555
}
5656

5757

@@ -61,14 +61,14 @@ def make_date(date):
6161
# yaml.allow_unicode = True
6262
# yaml.indent(sequence=4, offset=2, mapping=4)
6363
def dump(data, dest):
64-
# yaml.dump(data, dest)
65-
ruamel.yaml.dump(
66-
data,
67-
dest,
68-
explicit_start=True,
69-
allow_unicode=True,
70-
Dumper=ruamel.yaml.RoundTripDumper
71-
)
64+
# yaml.dump(data, dest)
65+
ruamel.yaml.dump(
66+
data,
67+
dest,
68+
explicit_start=True,
69+
allow_unicode=True,
70+
Dumper=ruamel.yaml.RoundTripDumper,
71+
)
7272

7373

7474
dest = sys.stdout

0 commit comments

Comments
 (0)
Please sign in to comment.