diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-07-31 15:22:41 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-03 10:50:14 -0700 |
commit | 942d0243c8bb718a39a9d0f2fbfa911ce7c27443 (patch) | |
tree | f7f5c628290bafe26c1ba1e0d549c70ad46756f8 | |
parent | c0e77976987199e1f77e9b7d0b188656d1f5456e (diff) | |
download | chocula-942d0243c8bb718a39a9d0f2fbfa911ce7c27443.tar.gz chocula-942d0243c8bb718a39a9d0f2fbfa911ce7c27443.zip |
sim: some flag fields as boolean
-rw-r--r-- | chocula/directories/sim.py | 14 |
1 files 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( |