aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/state_impl
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-08-29 20:58:18 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-28 12:54:55 +0200
commite48615157e6fc518d9800a1c17796c66295989d5 (patch)
treed864f46bda9190344700762a75237cebc7458231 /src/hydrilla/proxy/state_impl
parent3a9d28cdae6e726454e360a4f8411aad60993dd7 (diff)
downloadhaketilo-hydrilla-e48615157e6fc518d9800a1c17796c66295989d5.tar.gz
haketilo-hydrilla-e48615157e6fc518d9800a1c17796c66295989d5.zip
[server][proxy] use new ItemType enum where possible
Diffstat (limited to 'src/hydrilla/proxy/state_impl')
-rw-r--r--src/hydrilla/proxy/state_impl/_operations/load_packages.py16
-rw-r--r--src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py2
2 files changed, 7 insertions, 11 deletions
diff --git a/src/hydrilla/proxy/state_impl/_operations/load_packages.py b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
index f8fddfa..ca6baba 100644
--- a/src/hydrilla/proxy/state_impl/_operations/load_packages.py
+++ b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
@@ -271,7 +271,7 @@ def _add_item(
repo_iteration_id: int,
repo_id: int
) -> None:
- item_id = get_or_make_item(cursor, info.type_name, info.identifier)
+ item_id = get_or_make_item(cursor, info.type.value, info.identifier)
if isinstance(info, item_infos.MappingInfo):
make_mapping_status(cursor, item_id)
@@ -343,9 +343,9 @@ AnyInfoVar = t.TypeVar(
item_infos.MappingInfo
)
-def _read_items(malcontent_path: Path, item_class: t.Type[AnyInfoVar]) \
+def _read_items(malcontent_path: Path, info_class: t.Type[AnyInfoVar]) \
-> t.Iterator[tuple[AnyInfoVar, bytes]]:
- item_type_path = malcontent_path / item_class.type_name
+ item_type_path = malcontent_path / info_class.type.value
if not item_type_path.is_dir():
return
@@ -355,7 +355,7 @@ def _read_items(malcontent_path: Path, item_class: t.Type[AnyInfoVar]) \
for item_version_path in item_path.iterdir():
definition = item_version_path.read_bytes()
- item_info = item_class.load(definition)
+ item_info = info_class.load(definition)
assert item_info.identifier == item_path.name
assert versions.version_string(item_info.version) == \
@@ -383,15 +383,11 @@ def _load_packages_no_state_update(
repo_iteration_id = make_repo_iteration(cursor, repo_id)
- types: t.Iterable[t.Type[item_infos.AnyInfo]] = \
- [item_infos.ResourceInfo, item_infos.MappingInfo]
-
- for info_type in types:
+ for type in [item_infos.ItemType.RESOURCE, item_infos.ItemType.MAPPING]:
info: item_infos.AnyInfo
-
for info, definition in _read_items( # type: ignore
malcontent_path,
- info_type
+ type.info_class
):
_add_item(
cursor = cursor,
diff --git a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
index 327a195..b62004c 100644
--- a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
+++ b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
@@ -62,7 +62,7 @@ def _get_infos_of_type(cursor: sqlite3.Cursor, info_type: t.Type[AnyInfoVar],) \
WHERE
i.type = ?;
''',
- (info_type.type_name[0].upper(),)
+ (info_type.type.value[0].upper(),)
)
result: dict[int, AnyInfoVar] = {}