Skip to content

Commit dce7db5

Browse files
committed
Fix formatting issues in zenodo_fetch.py
1 parent 2dc3ec4 commit dce7db5

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

scripts/1-fetch/zenodo_fetch.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
This implementation uses Zenodo's REST API instead of OAI-PMH for more reliable
77
license detection. Benefits include:
8-
- Structured license data (metadata.license.id)
8+
- Structured license data (metadata.license.id)
99
- Clear separation of access rights
10-
- JSON parsing
10+
- JSON parsing
1111
- Standardized license identifiers
1212
"""
1313
# Standard library
@@ -57,7 +57,7 @@
5757
# CC License mapping for Zenodo API
5858
cc_license_mapping = {
5959
"cc-by": "CC BY 4.0",
60-
"cc-by-sa": "CC BY-SA 4.0",
60+
"cc-by-sa": "CC BY-SA 4.0",
6161
"cc-by-nc": "CC BY-NC 4.0",
6262
"cc-by-nd": "CC BY-ND 4.0",
6363
"cc-by-nc-sa": "CC BY-NC-SA 4.0",
@@ -237,17 +237,17 @@ def classify_license(license_data):
237237
# Special cases that need custom mapping
238238
special_cases = {
239239
"cc-zero": "CC0",
240-
"cc0-1.0": "CC0",
240+
"cc0-1.0": "CC0",
241241
"cc0": "CC0",
242242
"cc-nc": "CC BY-NC 4.0",
243-
"cc-nd": "CC BY-ND 4.0",
243+
"cc-nd": "CC BY-ND 4.0",
244244
"cc-sa": "CC BY-SA 4.0",
245245
"cc-publicdomain": "Public Domain Mark 1.0",
246246
}
247-
247+
248248
if license_id in special_cases:
249249
return special_cases[license_id]
250-
250+
251251
# Normalize standard CC licenses: cc-by-4.0 -> CC BY 4.0
252252
if license_id.startswith("cc-by"):
253253
return license_id.upper().replace("-", " ")
@@ -281,16 +281,17 @@ def fetch_zenodo_records(session, page=1, size=100, query="*"):
281281
}
282282

283283
try:
284-
response = session.get(
285-
ZENODO_API_BASE_URL, params=params, timeout=15
286-
)
284+
response = session.get(ZENODO_API_BASE_URL, params=params, timeout=15)
287285
response.raise_for_status()
288286
return response.json()
289287
except requests.RequestException as e:
290-
raise shared.QuantifyingException(f"Error fetching Zenodo records: {e}")
288+
raise shared.QuantifyingException(
289+
f"Error fetching Zenodo records: {e}"
290+
)
291291
except json.JSONDecodeError as e:
292292
raise shared.QuantifyingException(f"Error parsing JSON response: {e}")
293293

294+
294295
def extract_record_info(record_json):
295296
"""
296297
Extract information from a Zenodo REST API record.
@@ -413,7 +414,9 @@ def main():
413414
session, page=page, size=records_per_page, query=query
414415
)
415416
except (requests.RequestException, json.JSONDecodeError) as e:
416-
raise shared.QuantifyingException(f"Failed to fetch Zenodo records: {e}")
417+
raise shared.QuantifyingException(
418+
f"Failed to fetch Zenodo records: {e}"
419+
)
417420

418421
if not response_data or "hits" not in response_data:
419422
raise shared.QuantifyingException(

0 commit comments

Comments
 (0)