MCPcopy Create free account
hub / github.com/HzaCode/OneCite / _query_datacite

Method _query_datacite

onecite/pipeline/identifier.py:381–412  ·  view source on GitHub ↗

Query DataCite API for dataset metadata

(self, doi: str)

Source from the content-addressed store, hash-verified

379 return None
380
381 def _query_datacite(self, doi: str) -> Optional[Dict]:
382 """Query DataCite API for dataset metadata"""
383 try:
384 url = f"{self.datacite_base}/dois/{doi}"
385 response = requests.get(url, timeout=10)
386
387 if response.status_code == 200:
388 data = response.json()
389 attributes = data.get('data', {}).get('attributes', {})
390
391 creators = attributes.get('creators', [])
392 authors = [c.get('name', '') for c in creators if c.get('name')]
393
394 pub_year = attributes.get('publicationYear')
395
396 return {
397 'source': 'datacite',
398 'type': 'dataset',
399 'is_dataset': True,
400 'doi': doi,
401 'title': attributes.get('titles', [{}])[0].get('title', '') if attributes.get('titles') else '',
402 'authors': authors,
403 'year': pub_year,
404 'publisher': attributes.get('publisher', 'DataCite'),
405 'url': attributes.get('url', f"https://doi.org/{doi}"),
406 'resource_type': attributes.get('types', {}).get('resourceTypeGeneral', 'Dataset')
407 }
408
409 except Exception as e:
410 self.logger.warning(f"DataCite query failed for {doi}: {str(e)}")
411
412 return None
413
414 def _detect_thesis(self, text: str) -> Optional[Dict]:
415 """Detect and search for thesis/dissertation"""

Callers 4

test_successMethod · 0.95
test_404_returns_noneMethod · 0.95
_extract_zenodo_infoMethod · 0.95

Calls 1

jsonMethod · 0.45

Tested by 2

test_successMethod · 0.76
test_404_returns_noneMethod · 0.76