INNER CODE UNIT · Python
_load_claude_modules
CassiopeiaCode/q2api · app.py:92
def _load_claude_modules():
# claude_types
spec_types = importlib.util.spec_from_file_location("v2_claude_types", str(BASE_DIR / "claude_types.py"))
mod_types = importlib.util.module_from_spec(spec_types)
spec_types.loader.exec_module(mod_types)
# claude_converter
spec_conv = importlib.util.spec_from_file_location("v2_claude_converter", str(BASE_DIR / "claude_converter.py"))
mod_conv = importlib.util.module_from_spec(spec_conv)
# We need to inject claude_types into converter's namespace if it uses relative imports or expects them
# But since we used relative import in claude_converter.py (.claude_types), we need to be careful.
# Actually, since we are loading dynamically, relative imports might fail if not in sys.modules correctly.
# Let's patch sys.modules temporarily or just rely on file location.
# A simpler way for this single-file script style is to just load them.
# However, claude_converter does `from .claude_types import ...`
# To make that work, we should probably just use standard import if v2 is a package,
# but v2 is just a folder.
# Let's assume the user runs this with v2 in pythonpath or we just fix imports in the files.