aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/schema.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-07-26 15:11:44 -0700
committerBryan Newbold <bnewbold@archive.org>2021-07-26 15:11:44 -0700
commiteeb456c16d016d8523023f787597efae7a6317b9 (patch)
tree6b79a50b0d4d2c150f3d3a3411ba831fd46358ec /fatcat_scholar/schema.py
parent51a36f5e6069efedef0fbcd0ba319ced8f28eba4 (diff)
downloadfatcat-scholar-eeb456c16d016d8523023f787597efae7a6317b9.tar.gz
fatcat-scholar-eeb456c16d016d8523023f787597efae7a6317b9.zip
better parsing of year as integer in refs pipeline
Diffstat (limited to 'fatcat_scholar/schema.py')
-rw-r--r--fatcat_scholar/schema.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/fatcat_scholar/schema.py b/fatcat_scholar/schema.py
index bc6b016..0fcf56e 100644
--- a/fatcat_scholar/schema.py
+++ b/fatcat_scholar/schema.py
@@ -301,9 +301,12 @@ class RefTarget(BaseModel):
def clean_small_int(raw: Optional[str]) -> Optional[int]:
- if not raw or not raw.isdigit():
+ if not raw or not raw.strip().isdigit():
+ return None
+ try:
+ val = int(raw.strip())
+ except ValueError:
return None
- val = int(raw)
if abs(val) > 30000:
return None
return val
@@ -318,6 +321,7 @@ def test_clean_small_int() -> None:
assert clean_small_int("1200003") == None
assert clean_small_int("-123") == None
assert clean_small_int("48844") == None
+ assert clean_small_int("1990²") == None
def doi_split_prefix(doi: str) -> str: