Files
cali_scraper/scripts/_iso.py
T
2026-09-06 10:18:26 -07:00

39 lines
1.5 KiB
Python

"""Verify parser-core modules load and work, as a real package but with a
STUB __init__ (so we do NOT run the sibling's scraper/__init__.py, which
imports the in-progress ingest layer and is currently broken).
"""
import importlib.util, sys, types, traceback
PKG = "scrpkr" # isolated namespace, does not touch sibling's `scraper`
spec = importlib.util.spec_from_file_location(PKG, "scraper/__init__.py")
# Build a stub package (no __init__ body executed) with submodules.
pkgmod = types.ModuleType(PKG)
pkgmod.__path__ = ["scraper"]
sys.modules[PKG] = pkgmod
def load(sub):
name = f"{PKG}.{sub}"
s = importlib.util.spec_from_file_location(name, f"scraper/{sub}.py")
m = importlib.util.module_from_spec(s)
sys.modules[name] = m
s.loader.exec_module(m)
return m
try:
schema = load("schema")
bill_id = load("bill_id")
parsers = load("parsers")
io_mod = load("io")
cli = load("cli")
print("OK schema :", [n for n in dir(schema) if not n.startswith('_')][:6])
print("OK bill_id:", [n for n in dir(bill_id) if not n.startswith('_')][:6])
print("OK parsers:", [n for n in dir(parsers) if not n.startswith('_') and callable(getattr(parsers,n))][:12])
print("OK io :", [n for n in dir(io_mod) if not n.startswith('_') and callable(getattr(io_mod,n))])
print("OK cli :", callable(cli.main), "argparse subcommands ok")
dec = bill_id.parse_bill_id("202520260AB28")
print("codec 202520260AB28 ->", dec)
print("ALL CORE MODULES OK")
except Exception:
traceback.print_exc()
sys.exit(1)