mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-15 06:14:35 +01:00
refactor: Refactor config
This commit is contained in:
@@ -2,17 +2,19 @@ import json
|
||||
import traceback
|
||||
from typing import Dict, Type, TypeVar, Optional, Any, List
|
||||
|
||||
from game_server.config.log import Error, Info
|
||||
from utils.logger import Error, Info
|
||||
from game_server.resource.base_resource import BaseResource
|
||||
from game_server.resource.decorators import resource_registry
|
||||
import game_server.resource.configdb # noqa: F401
|
||||
|
||||
T = TypeVar("T", bound=BaseResource)
|
||||
|
||||
|
||||
def filter_data(cls: Type, data):
|
||||
valid_fields = cls.__annotations__.keys()
|
||||
return {field: data.get(field, None) for field in valid_fields}
|
||||
|
||||
|
||||
class ResourceManager:
|
||||
def __init__(self):
|
||||
self.data: Dict[Type[T], Dict[Any, T]] = {}
|
||||
@@ -57,4 +59,5 @@ class ResourceManager:
|
||||
def instance():
|
||||
return resource_manager
|
||||
|
||||
|
||||
resource_manager = ResourceManager()
|
||||
|
||||
Reference in New Issue
Block a user