diff --git a/torappu/config.py b/torappu/config.py index a40e4b2..c387659 100644 --- a/torappu/config.py +++ b/torappu/config.py @@ -3,16 +3,16 @@ from pydantic_settings import BaseSettings, SettingsConfigDict -from torappu.consts import MACOS, WINDOWS +from torappu.consts import BASE_DIR, MACOS, WINDOWS def get_flatc_path(): if WINDOWS: - return Path("bin/flatc.exe") + return Path(BASE_DIR / "bin/flatc.exe") elif MACOS: - return Path("bin/macos/flatc") + return Path(BASE_DIR / "bin/macos/flatc") else: - return Path("bin/flatc") + return Path(BASE_DIR / "bin/flatc") class Config(BaseSettings): diff --git a/torappu/core/__init__.py b/torappu/core/__init__.py index a17a97b..4a6be38 100644 --- a/torappu/core/__init__.py +++ b/torappu/core/__init__.py @@ -75,3 +75,36 @@ async def main( continue tg.start_soon(check_and_run_task, task(client), diff) + + +async def export_client( + version: Version, + prev: Version | None, + exclude: list[str], + include: list[str], +): + if prev == version: + logger.info("Version did not change, skipping running") + return + + client = Client(version, prev, config) + try: + await client.init() + except Exception as e: + logger.opt(exception=e).error("Failed to init client") + return + + diff = client.diff() + for priority in sorted(registry.keys()): + logger.info(f"Checking for tasks in priority {priority}...") + + async with anyio.create_task_group() as tg: + for task in registry[priority]: + input_name = task.__name__ + if (exclude and input_name in exclude) or ( + include and input_name not in include + ): + continue + + tg.start_soon(check_and_run_task, task(client), diff) + return client diff --git a/torappu/core/client.py b/torappu/core/client.py index e8d112c..97ea952 100644 --- a/torappu/core/client.py +++ b/torappu/core/client.py @@ -14,6 +14,7 @@ from torappu.config import Config from torappu.consts import ( + BASE_DIR, GAMEDATA_DIR, HEADERS, HG_CN_BASEURL, @@ -224,7 +225,7 @@ def load_idx(self, idx_path: str, decoded_path: Path): "--natural-utf8", "--defaults-json", "--raw-binary", - "assets/ResourceManifest.fbs", + str(Path(BASE_DIR / "assets/ResourceManifest.fbs")), "--", flatbuffer_data_path, ]