Skip to content

Commit

Permalink
remove dump & restore functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
enku committed Feb 17, 2025
1 parent dca806b commit bf803fc
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 945 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ addrepo = "gentoo_build_publisher.cli.addrepo"
apikey = "gentoo_build_publisher.cli.apikey"
check = "gentoo_build_publisher.cli.check"
delete = "gentoo_build_publisher.cli.delete"
dump = "gentoo_build_publisher.cli.dump"
restore = "gentoo_build_publisher.cli.restore"
worker = "gentoo_build_publisher.cli.worker"

[project.entry-points."gentoo_build_publisher.graphql_schema"]
Expand Down
106 changes: 0 additions & 106 deletions src/gentoo_build_publisher/cli/dump.py

This file was deleted.

49 changes: 0 additions & 49 deletions src/gentoo_build_publisher/cli/restore.py

This file was deleted.

11 changes: 1 addition & 10 deletions src/gentoo_build_publisher/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import datetime as dt
from dataclasses import dataclass, field
from enum import Enum, unique
from typing import Any, Callable, Literal, Protocol, TypeAlias
from typing import Any, Protocol

from gentoo_build_publisher import utils

Expand Down Expand Up @@ -170,12 +170,3 @@ class ApiKey:

def __post_init__(self) -> None:
utils.validate_identifier(self.name)


DumpType: TypeAlias = Literal["dump"] | Literal["restore"]
DumpPhase: TypeAlias = Literal["storage"] | Literal["records"]
DumpCallback: TypeAlias = Callable[[DumpType, DumpPhase, Build], Any]


def default_dump_callback(_type: DumpType, _phase: DumpPhase, _build: Build) -> None:
"""Default DumpCallback. A noop"""
30 changes: 0 additions & 30 deletions src/gentoo_build_publisher/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,33 +293,3 @@ def _(value: dt.date | dt.datetime) -> str:


_RESOLVERS: dict[type, dict[str, Callable[[Any], Any]]] = {}


def decode_to(type_: type[_T], data: dict[str, Any]) -> _T:
"""Use the given data dict to initialize the given type
Converts a JSON-compatible dict into the given type based on the registered
converters for that type.
"""
new_data = {}
for key, value in data.items():
if resolver := _RESOLVERS.get(type_, {}).get(key):
new_value = resolver(value)
else:
new_value = value
new_data[key] = new_value

if len(new_data) == 1:
return type_(*new_data.values())
return type_(**new_data)


def convert_to(type_: type, field: str) -> Callable[[Any], Any]:
"""Resolve the given datatype field of the given type"""

def decorate(func: Callable[[Any], Any]) -> Callable[[Any], Any]:
resolvers_of_type = _RESOLVERS.setdefault(type_, {})
resolvers_of_type[field] = func
return func

return decorate
93 changes: 0 additions & 93 deletions src/gentoo_build_publisher/utils/archive/__init__.py

This file was deleted.

43 changes: 0 additions & 43 deletions src/gentoo_build_publisher/utils/archive/metadata.py

This file was deleted.

Loading

0 comments on commit bf803fc

Please sign in to comment.