Skip to content

Commit

Permalink
Add datasette info into datapackage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Sep 23, 2023
1 parent 7d04a70 commit e3ee4f4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/data_common/dataset/resource_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,25 @@ def get_current_datapackage_json(self) -> dict[str, Any]:
"""
datapackage = self.get_datapackage()
datapackage["resources"] = [x.get_resource() for x in self.resources().values()]
for resource in datapackage["resources"]:
if "custom" not in resource:
resource["custom"] = {}
if "datasette" not in resource["custom"]:
resource["custom"]["datasette"] = {}
if "about" not in resource["custom"]["datasette"]:
resource["custom"]["datasette"]["about"] = "Info & Downloads"
resource["custom"]["datasette"][
"about_url"
] = f"{self.url}#{resource['name']}"
if "custom" not in datapackage:
datapackage["custom"] = {}
if "dataset_order" not in datapackage["custom"]:
datapackage["custom"]["dataset_order"] = 999
if "dataset_order" not in datapackage["custom"]:
datapackage["custom"]["dataset_order"] = 999
if "datasette" not in ["custom"]:
datapackage["custom"]["datasette"] = {}
if "about" not in datapackage["custom"]["datasette"]:
datapackage["custom"]["datasette"]["about"] = "Info & Downloads"
datapackage["custom"]["datasette"]["about_url"] = self.url
return datapackage

def build_json(self):
Expand Down

0 comments on commit e3ee4f4

Please sign in to comment.