From ff420e131fb07db9d8ef7b70b2bce1ffc2d41df7 Mon Sep 17 00:00:00 2001 From: NotSoToothless <67082114+FURRO404@users.noreply.github.com> Date: Wed, 13 May 2026 23:30:15 -0700 Subject: [PATCH] fix relative .data_parser imports in BOT/* after SHARED move (#1224) PR #1223 + fixup moved data_parser into BOTS/SHARED, but five BOT modules (analytics, autologging, botscript, lux_apis, meta_manager) still used `from .data_parser import ...`. That relative form looks inside the BOT package, which no longer contains data_parser, so the bot crashed at startup with ModuleNotFoundError. Add BOT/__init__.py to put BOTS/SHARED on sys.path at package import, then switch all five files to absolute `from data_parser import ...`. Co-authored-by: Claude Opus 4.7 (1M context) --- BOT/__init__.py | 12 ++++++++++++ BOT/analytics.py | 2 +- BOT/autologging.py | 2 +- BOT/botscript.py | 2 +- BOT/lux_apis.py | 2 +- BOT/meta_manager.py | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 BOT/__init__.py diff --git a/BOT/__init__.py b/BOT/__init__.py new file mode 100644 index 0000000..693a8a3 --- /dev/null +++ b/BOT/__init__.py @@ -0,0 +1,12 @@ +"""SREBOT bot package. + +Bootstraps the sibling BOTS/SHARED directory onto sys.path so that +`from data_parser import ...` (and other SHARED-only modules) resolve +regardless of which submodule gets imported first. +""" +import sys +from pathlib import Path + +_SHARED_DIR = Path(__file__).resolve().parents[2] / "SHARED" +if str(_SHARED_DIR) not in sys.path: + sys.path.insert(0, str(_SHARED_DIR)) diff --git a/BOT/analytics.py b/BOT/analytics.py index 2f764fc..34c3a5f 100644 --- a/BOT/analytics.py +++ b/BOT/analytics.py @@ -17,7 +17,7 @@ from datetime import datetime, timezone import aiosqlite # Local Module Imports -from .data_parser import get_unit_type_abbrev +from data_parser import get_unit_type_abbrev from .utils import SQ_BATTLES_DB_PATH, decompress_json diff --git a/BOT/autologging.py b/BOT/autologging.py index fa65902..a616945 100644 --- a/BOT/autologging.py +++ b/BOT/autologging.py @@ -27,7 +27,7 @@ import pygob # Local Module Imports from . import utils -from .data_parser import LangTableReader +from data_parser import LangTableReader from .game_api import get_point_diff from .gob import load_gob_file, render_gob from .health import record_game_processed, record_ws_message diff --git a/BOT/botscript.py b/BOT/botscript.py index a70bb81..e364fdd 100644 --- a/BOT/botscript.py +++ b/BOT/botscript.py @@ -46,7 +46,7 @@ from .analytics import ( get_time_performance, get_matchup_history, ) from .autologging import init_players_db, load_replay_data_from_disk, build_scoreboard_view -from .data_parser import LangTableReader, count_unit_types, get_unit_type_abbrev, normalize_name +from data_parser import LangTableReader, count_unit_types, get_unit_type_abbrev, normalize_name from .game_api import ( ClanInfoError, obtain_clan_info_api, diff --git a/BOT/lux_apis.py b/BOT/lux_apis.py index e252588..30f6599 100644 --- a/BOT/lux_apis.py +++ b/BOT/lux_apis.py @@ -22,7 +22,7 @@ from websockets.asyncio.client import connect as wsconnect # Local Module Imports try: - from .data_parser import LangTableReader + from data_parser import LangTableReader from .utils import REPLAYS_DIR except ImportError: LangTableReader = None # Running directly, not as module diff --git a/BOT/meta_manager.py b/BOT/meta_manager.py index bec6abb..44f72c7 100644 --- a/BOT/meta_manager.py +++ b/BOT/meta_manager.py @@ -17,7 +17,7 @@ from typing import Any, Dict, List, Tuple, Optional import aiosqlite # Local Module Imports -from .data_parser import LangTableReader, normalize_name +from data_parser import LangTableReader, normalize_name from .game_api import obtain_clan_new_points, obtain_player_data_api from .utils import STORAGE_DIR, SQUADRONS_DB_PATH, compress_json, decompress_json