From 942d0243c8bb718a39a9d0f2fbfa911ce7c27443 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 31 Jul 2020 15:22:41 -0700 Subject: sim: some flag fields as boolean --- chocula/directories/sim.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chocula/directories/sim.py b/chocula/directories/sim.py index fedcc29..1eb29be 100644 --- a/chocula/directories/sim.py +++ b/chocula/directories/sim.py @@ -10,6 +10,16 @@ from chocula.common import DirectoryLoader from chocula.database import DirectoryInfo +def truthy(raw: Optional[str]) -> Optional[bool]: + if not raw: + return None + if raw.lower() == 'y': + return True + if raw.lower() == 'n': + return False + return None + + class SimLoader(DirectoryLoader): source_slug = "sim" @@ -57,8 +67,8 @@ class SimLoader(DirectoryLoader): extra["gaps"] = gaps if first_year and last_year: extra["year_spans"] = gaps_to_spans(first_year, last_year, gaps) - extra["scholarly_peer_reviewed"] = row["Scholarly / Peer-\nReviewed"] - extra["peer_reviewed"] = row["Peer-\nReviewed"] + extra["scholarly_peer_reviewed"] = truthy(clean_str(row["Scholarly / Peer-\nReviewed"])) + extra["peer_reviewed"] = truthy(clean_str(row["Peer-\nReviewed"])) extra["pub_type"] = clean_str(row["Pub Type"]) info = DirectoryInfo( -- cgit v1.2.3