|
16 | 16 | import requests_cache |
17 | 17 | from rapidfuzz import fuzz |
18 | 18 |
|
19 | | -import colrev.env.environment_manager |
20 | 19 | import colrev.exceptions as colrev_exceptions |
21 | 20 | import colrev.record.record_prep |
22 | 21 | import colrev.utils |
@@ -329,15 +328,21 @@ def __init__( |
329 | 328 | self, |
330 | 329 | *, |
331 | 330 | url: str, |
| 331 | + email: str = "my@email.edu", |
332 | 332 | rerun: bool = False, |
333 | 333 | cache: typing.Optional[bool] = None, |
334 | 334 | ): |
335 | 335 | assert url.startswith(self._api_url) |
336 | 336 | self.url = url |
337 | 337 |
|
338 | | - _, self.email = ( |
339 | | - colrev.env.environment_manager.EnvironmentManager.get_name_mail_from_git() |
340 | | - ) |
| 338 | + self.email = email |
| 339 | + if email == "my@email.edu": |
| 340 | + # warn |
| 341 | + print( |
| 342 | + "Warning: Using default email for Crossref API. " |
| 343 | + "Please set a valid email to comply with Crossref's polite usage policy." |
| 344 | + ) |
| 345 | + |
341 | 346 | self.rerun = rerun |
342 | 347 | # default: disable cache in CI; but allow explicit override |
343 | 348 | if cache is None: |
@@ -597,13 +602,12 @@ def _norm_doi(doi: str) -> str: |
597 | 602 | return record_list |
598 | 603 |
|
599 | 604 |
|
600 | | -def query_doi(*, doi: str) -> colrev.record.record_prep.PrepRecord: |
| 605 | +def query_doi( |
| 606 | + *, doi: str, email: str = "my@email.edu" |
| 607 | +) -> colrev.record.record_prep.PrepRecord: |
601 | 608 | """Get records from Crossref based on a doi query""" |
602 | 609 |
|
603 | 610 | try: |
604 | | - _, email = ( |
605 | | - colrev.env.environment_manager.EnvironmentManager.get_name_mail_from_git() |
606 | | - ) |
607 | 611 | endpoint = Endpoint("https://api.crossref.org/works/" + doi, email=email) |
608 | 612 |
|
609 | 613 | crossref_query_return = next(iter(endpoint)) |
|
0 commit comments