-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,8 @@ | ||
from mp_api.core.client import BaseRester, MPRestError | ||
from mp_api.core.client import BaseRester | ||
from mp_api.routes.dois.models import DOIDoc | ||
|
||
|
||
class DOIRester(BaseRester): | ||
|
||
suffix = "doi" | ||
document_model = DOIDoc # type: ignore | ||
|
||
def get_eos_from_material_id(self, material_id: str): | ||
""" | ||
Get DOI and reference data for a given Materials Project ID. | ||
Arguments: | ||
material_id (str): Materials project ID | ||
Returns: | ||
results (Dict): Dictionary containing DOI and reference data of state data. | ||
""" | ||
|
||
result = self._make_request("{}/?all_fields=true".format(material_id)) | ||
|
||
if len(result.get("data", [])) > 0: | ||
return result | ||
else: | ||
raise MPRestError("No document found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import List, Optional | ||
from mp_api.routes.dois.models import DOIDoc | ||
|
||
|
||
class DOIRester: | ||
|
||
def get_document_by_id( | ||
self, | ||
document_id: str, | ||
fields: Optional[List[str]] = None, | ||
monty_decode: bool = True, | ||
version: Optional[str] = None, | ||
) -> DOIDoc: ... |