From 99e67b079f8d3267e9bbd53bbdb9cf729be61d87 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 31 Jul 2020 15:23:17 -0700 Subject: directories: all extra metadata in top-level dict Had been using slug-specific sub-objects, but this was too confusing. --- chocula/database.py | 10 +++------- chocula/directories/norwegian.py | 4 ++-- chocula/directories/sherpa_romeo.py | 2 +- chocula/directories/szczepanski.py | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/chocula/database.py b/chocula/database.py index f30ceb5..0820e0f 100644 --- a/chocula/database.py +++ b/chocula/database.py @@ -511,15 +511,11 @@ class ChoculaDatabase: out["lang"] = extra["langs"][0] if irow["slug"] in ("doaj", "road", "szczepanski", "gold_oa"): out["is_oa"] = True - if irow["slug"] == "ezb": - ezb_extra = json.loads(irow["extra"]) - if ezb_extra["ezb_color"] == "green": - out["is_oa"] = True if irow["slug"] == "sherpa_romeo": extra = json.loads(irow["extra"]) - if extra.get("sherpa_romeo"): - out["sherpa_color"] = extra["sherpa_romeo"]["color"] - if extra["sherpa_romeo"].get("color") == "green": + if extra.get("color"): + out["sherpa_color"] = extra["color"] + if extra["color"] == "green": out["is_oa"] = True # filter out "NA" ISSNs diff --git a/chocula/directories/norwegian.py b/chocula/directories/norwegian.py index 8bfa19a..74167a0 100644 --- a/chocula/directories/norwegian.py +++ b/chocula/directories/norwegian.py @@ -67,9 +67,9 @@ class NorwegianLoader(DirectoryLoader): langs=[lang for lang in [parse_lang(row["Language"])] if lang], ) - info.extra["norwegian"] = dict(as_of=self.config.norwegian.date) + info.extra["as_of"] = self.config.norwegian.date if row["Level 2019"]: - info.extra["norwegian"]["level"] = int(row["Level 2019"]) + info.extra["level"] = int(row["Level 2019"]) if row["Original title"] != row["International title"]: info.original_name = clean_str(row["Original title"]) diff --git a/chocula/directories/sherpa_romeo.py b/chocula/directories/sherpa_romeo.py index a8ba1b0..5618302 100644 --- a/chocula/directories/sherpa_romeo.py +++ b/chocula/directories/sherpa_romeo.py @@ -58,6 +58,6 @@ class SherpaRomeoLoader(DirectoryLoader): ) if row["RoMEO colour"]: - info.extra["sherpa_romeo"] = dict(color=row["RoMEO colour"]) + info.extra["color"] = row["RoMEO colour"] return info diff --git a/chocula/directories/szczepanski.py b/chocula/directories/szczepanski.py index 3586acb..88e35a8 100644 --- a/chocula/directories/szczepanski.py +++ b/chocula/directories/szczepanski.py @@ -33,12 +33,12 @@ class SzczepanskiLoader(DirectoryLoader): publisher=clean_str(row.get("ed")), ) - info.extra["szczepanski"] = dict(as_of=self.config.szczepanski.date) + info.extra["as_of"] = self.config.szczepanski.date if row.get("extra"): - info.extra["szczepanski"]["notes"] = row.get("extra") + info.extra["notes"] = row.get("extra") for k in ("other_titles", "year_spans", "ed"): if row.get(k): - info.extra["szczepanski"][k] = row[k] + info.extra[k] = row[k] url = HomepageUrl.from_url(row.get("url")) if url: -- cgit v1.2.3