Initial commit
This commit is contained in:
commit
5f2db08b43
100 files changed
+16985
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""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)
|
||||
Reference in new issue
Block a user