import_economics.py 2,620 → 309 lines — a thin orchestrator keeping the exact CLI, single-transaction/rollback contract, and exit codes. The 16 import steps, MIGRATION_SQL, brands shell-out, validators, and stamp write now live in tooling/economy-db/economy_import/ (db, migration, economy, corporations, brands, bodies, atlas, specialization, traits, validators, stamp, paths, errors). Full type hints throughout. tooling/generator_sources.py replaces the triplicated source registry (importer / stamp checker / pr-process watch list — the skill now derives its list via --list). The registry stamps itself, and economy_import/ modules are globbed fail-closed, so a future module is stamped the moment it exists — closing the silently-weakened-stamp failure mode. Rider: connector config helpers centralized in tooling/db/common.py. Byte-identical behavior proven: full-import table dump diff EMPTY over 107,843 lines / 37 tables (volatile timestamp fields excluded); dry-run output parity; generated_brands.toml sha unchanged. make test-tooling PASS; ruff clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
39 lines
1.8 KiB
Python
39 lines
1.8 KiB
Python
"""
|
|
economy_import — module package behind tooling/economy-db/import_economics.py.
|
|
|
|
Split out of the former single-file importer (T-1067). The entrypoint
|
|
``import_economics.py`` remains the CLI (Makefile regen-db, make test-tooling)
|
|
and orchestrates the single-transaction import; the steps live here:
|
|
|
|
paths.py source-file path constants (re-exports stamped paths
|
|
from tooling/generator_sources.py)
|
|
errors.py ImportAborted control-flow exception
|
|
db.py connection + FK-safe table-clear helpers
|
|
migration.py MIGRATION_SQL / COLUMN_MIGRATIONS schema migration
|
|
economy.py gate links, commodities, chains, currency zones,
|
|
gate energy, system_fiscal
|
|
corporations.py wiki corp parsing, D-182 sync, corp_presence
|
|
brands.py generate_brands shell-out + D-189 brand layer
|
|
bodies.py body_radius_km / axial_tilt_deg backfills
|
|
atlas.py atlas index schema + city-name pool (D-223, D-207)
|
|
specialization.py D-237 authored specialization layer
|
|
traits.py D-232 architecture-flavor trait templates + hero bias
|
|
validators.py structural + D-175 coverage validation
|
|
stamp.py meta-table generator stamp (#855, #856)
|
|
|
|
Every module here is part of the import_economics meta-stamp source set —
|
|
tooling/generator_sources.py globs this directory, so adding a module
|
|
automatically extends staleness detection.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Bootstrap: make tooling/ importable (generator_sources, schema_version)
|
|
# before any submodule needs them. tooling/economy-db is not a package
|
|
# (hyphenated dir), so the entrypoint puts it on sys.path and this package
|
|
# adds tooling/ itself.
|
|
_TOOLING_DIR = Path(__file__).resolve().parents[2]
|
|
if str(_TOOLING_DIR) not in sys.path:
|
|
sys.path.insert(0, str(_TOOLING_DIR))
|