diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-29 20:58:18 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-28 12:54:55 +0200 |
commit | e48615157e6fc518d9800a1c17796c66295989d5 (patch) | |
tree | d864f46bda9190344700762a75237cebc7458231 /src/hydrilla/server | |
parent | 3a9d28cdae6e726454e360a4f8411aad60993dd7 (diff) | |
download | haketilo-hydrilla-e48615157e6fc518d9800a1c17796c66295989d5.tar.gz haketilo-hydrilla-e48615157e6fc518d9800a1c17796c66295989d5.zip |
[server][proxy] use new ItemType enum where possible
Diffstat (limited to 'src/hydrilla/server')
-rw-r--r-- | src/hydrilla/server/malcontent.py | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/hydrilla/server/malcontent.py b/src/hydrilla/server/malcontent.py index ce24330..af925a0 100644 --- a/src/hydrilla/server/malcontent.py +++ b/src/hydrilla/server/malcontent.py @@ -120,12 +120,8 @@ class Malcontent: fmt = _('err.server.malcontent_path_not_dir_{}') raise HaketiloException(fmt.format(malcontent_dir_path)) - types: t.Iterable[t.Type[item_infos.AnyInfo]] = ( - item_infos.MappingInfo, - item_infos.ResourceInfo - ) - for info_type in types: - type_path = self.malcontent_dir_path / info_type.type_name + for type in [item_infos.ItemType.RESOURCE, item_infos.ItemType.MAPPING]: + type_path = self.malcontent_dir_path / type.value if not type_path.is_dir(): continue @@ -135,7 +131,7 @@ class Malcontent: for ver_file in subpath.iterdir(): try: - self._load_item(info_type, ver_file) + self._load_item(type, ver_file) except: if self.werror: raise @@ -174,11 +170,8 @@ class Malcontent: versioned_info = infos.get(identifier, VersionedItemInfo()) infos[identifier] = versioned_info.register(item_info) - def _load_item( - self, - info_type: t.Type[item_infos.AnyInfo], - ver_file: Path - ) -> None: + def _load_item(self, type: item_infos.ItemType, ver_file: Path) \ + -> None: """ Reads, validates and autocompletes serveable mapping/resource definition, then registers information from it in data structures. @@ -186,7 +179,7 @@ class Malcontent: version = versions.parse(ver_file.name) identifier = ver_file.parent.name - item_info = info_type.load(ver_file) + item_info = type.info_class.load(ver_file) if item_info.identifier != identifier: fmt = _('err.server.item_{item}_in_file_{file}') |