ita_source_sections.py 540 B

123456789101112
  1. """Read one mechanically relocated section for existing boundary assertions."""
  2. from pathlib import Path
  3. import re
  4. def section(name):
  5. source = (Path(__file__).resolve().parents[2] / "plugins/ita_plugin.py").read_text()
  6. sections = re.split(r"\n# ={76}\n# (\w+) \(from plugins/ita_\w+\.py\)\n# ={76}\n", source)
  7. matches = [sections[i + 1] for i in range(1, len(sections), 2) if sections[i] == name.upper()]
  8. if len(matches) != 1:
  9. raise AssertionError(f"Missing/duplicate Italy section: {name}")
  10. return matches[0]