Skip to content

Commit

Permalink
refactor: Tidy up setting resource metadata from old resource
Browse files Browse the repository at this point in the history
  • Loading branch information
bellisk committed Oct 26, 2023
1 parent 9945bfa commit 065d781
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ckanext/switzerland/harvester/base_sbb_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class BaseSBBHarvester(HarvesterBase):
"rights": "",
"license": "",
"coverage": "Coverage",
"description": {"de": "", "en": "", "fr": "", "it": ""},
}

filters = {}
Expand Down Expand Up @@ -851,14 +852,16 @@ def _import_stage(self, harvest_object): # noqa
resource_meta["version"] = now

# take this metadata from the old version if available
resource_meta["rights"] = old_resource_meta.get("rights", "")
resource_meta["license"] = old_resource_meta.get("license", "")
resource_meta["coverage"] = old_resource_meta.get("coverage", "TODO")
resource_meta["description"] = old_resource_meta.get(
"description", {"de": "", "en": "", "fr": "", "it": ""}
)
resource_meta["relations"] = old_resource_meta.get("relations", [])
resource_meta["rights"] = old_resource_meta.get("rights", [])
fields_from_old_resource_meta = [
"rights",
"license",
"coverage",
"description",
"relations",
]
for field in fields_from_old_resource_meta:
if old_resource_meta.get(field):
resource_meta[field] = old_resource_meta.get(field)

resource_meta["package_id"] = dataset["id"]

Expand Down

0 comments on commit 065d781

Please sign in to comment.