Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consolidate: Use json5 over json #62

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions blueos_repository/consolidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, AsyncIterable, Dict, List, Optional, Union

import aiohttp
import json5
import semver
from registry import Registry

Expand Down Expand Up @@ -124,7 +125,7 @@ async def all_repositories(self) -> AsyncIterable[RepositoryEntry]:
company, extension_name = repo.as_posix().split("/")[-3:-1]
identifier = ".".join([company, extension_name])
try:
data = json.load(individual_file)
data = json5.load(individual_file)
except Exception as exc:
raise Exception(f"Unable to parse file {repo}") from exc
company_logo = (repo / "../../company_logo.png").resolve().relative_to(repos.resolve())
Expand Down Expand Up @@ -169,9 +170,9 @@ async def run(self) -> None:
continue
raw_labels = await self.registry.fetch_labels(f"{repository.docker}:{tag}")
permissions = raw_labels.get("permissions", None)
links = json.loads(raw_labels.get("links", "{}"))
links = json5.loads(raw_labels.get("links", "{}"))
website = links.pop("website", raw_labels.get("website", None))
authors = json.loads(raw_labels.get("authors", "[]"))
authors = json5.loads(raw_labels.get("authors", "[]"))
# documentation is just a URL for a link, but the old format had it as its own label
docs = links.pop("docs", links.pop("documentation", raw_labels.get("docs", None)))
readme = raw_labels.get("readme", None)
Expand All @@ -182,16 +183,16 @@ async def run(self) -> None:
except Exception as error: # pylint: disable=broad-except
readme = str(error)
company_raw = raw_labels.get("company", None)
company = Company.from_json(json.loads(company_raw)) if company_raw is not None else None
company = Company.from_json(json5.loads(company_raw)) if company_raw is not None else None
support = links.pop("support", raw_labels.get("support", None))
type_ = raw_labels.get("type", ExtensionType.OTHER)
filter_tags = json.loads(raw_labels.get("tags", "[]"))
filter_tags = json5.loads(raw_labels.get("tags", "[]"))

new_version = Version(
permissions=json.loads(permissions) if permissions else None,
permissions=json5.loads(permissions) if permissions else None,
website=website,
authors=authors,
docs=json.loads(docs) if docs else None,
docs=json5.loads(docs) if docs else None,
readme=readme,
company=company,
support=support,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ packages = [{include = "blueos_repository"}]

[tool.poetry.dependencies]
aiohttp = "3.7.4"
json-five = "1.1.1"
python = "^3.10"
semver = "^2.13.0"

Expand Down
Loading