summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/schema.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-01-21 19:25:09 -0800
committerBryan Newbold <bnewbold@archive.org>2021-01-21 19:36:21 -0800
commit05cd1bb7bdcefe8ec596e572baafb9da9a8838b2 (patch)
tree5c49a54bf594e5d0008264984e12e1d1a881c1fe /fatcat_scholar/schema.py
parent5096b0b7407aadfb97093615696f951829dc3506 (diff)
downloadfatcat-scholar-05cd1bb7bdcefe8ec596e572baafb9da9a8838b2.tar.gz
fatcat-scholar-05cd1bb7bdcefe8ec596e572baafb9da9a8838b2.zip
refactor DOI domain lookup into python code; expand table
Diffstat (limited to 'fatcat_scholar/schema.py')
-rw-r--r--fatcat_scholar/schema.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/fatcat_scholar/schema.py b/fatcat_scholar/schema.py
index d3a91a7..480b8fa 100644
--- a/fatcat_scholar/schema.py
+++ b/fatcat_scholar/schema.py
@@ -19,6 +19,7 @@ from pydantic import BaseModel
from fatcat_openapi_client import ReleaseEntity, ReleaseContrib
from fatcat_scholar.api_entities import entity_to_dict
+from fatcat_scholar.biblio_hacks import doi_link_domain
class DocType(str, Enum):
@@ -104,6 +105,19 @@ class ScholarBiblio(BaseModel):
contrib_names: List[str]
affiliations: List[str]
+ def doi_link_domain(self, default: str = "doi.org") -> str:
+ if not self.doi_prefix:
+ return default
+ domain = doi_link_domain(
+ self.doi_prefix,
+ container_name=self.container_name,
+ publisher=self.publisher,
+ )
+ if domain:
+ return domain
+ else:
+ return default
+
def citation_str(self, style: str) -> Optional[str]:
"""
Tries to format this biblio metadata as a citation string. If it fails,