Skip to content

Commit

Permalink
fix(packaging): publisher is an object with name attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
yshalenyk committed Jun 21, 2024
1 parent b5aa619 commit 1317d98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 3 additions & 4 deletions nightingale/publisher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from typing import Any

from .utils import produce_package_name
from .utils import get_iso_now, produce_package_name


class DataPublisher:
Expand Down Expand Up @@ -41,11 +40,11 @@ def package(self, data: list[dict[str, Any]]) -> dict[str, Any]:
:return: A dictionary representing the release package.
:rtype: dict[str, Any]
"""
now = datetime.now().isoformat()
now = get_iso_now()
return {
"uri": self.produce_uri(now),
"version": self.config.version,
"publisher": self.config.publisher,
"publisher": {"name": self.config.publisher},
"publishedDate": now,
"releases": data,
}
21 changes: 21 additions & 0 deletions nightingale/utils.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
from datetime import datetime


def produce_package_name(date):
return f"release-package-{date}.json"


def remove_dicts_without_id(data):
if isinstance(data, dict):
result = {}
for k, val in data.items():
if cleaned_v := remove_dicts_without_id(val):
result[k] = cleaned_v
return result
elif isinstance(data, list):
return [remove_dicts_without_id(item) for item in data if not (isinstance(item, dict) and "id" not in item)]
else:
return data


def get_iso_now():
now = datetime.utcnow()
return now.isoformat() + "Z"

0 comments on commit 1317d98

Please sign in to comment.