Rewrite PADS/BOM dispatch and EDIF ingest as Periscope parsers.
KiCad schematic parser and PCB via≠pad parser stay native. Inherited parser files remain in dependency/.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""Schematic parsers load from src; they do not classify PCB vias as pads."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import backend.periscopex.parsers as parsers
|
||||
import backend.periscopex.parsers_edif as parsers_edif
|
||||
import backend.periscopex.parsers_kicad_pcb as pcb
|
||||
from backend.periscopex.parsers import detect_netlist_format, parse_netlist_any
|
||||
|
||||
|
||||
def test_schematic_parsers_are_src():
|
||||
for mod, name in ((parsers, "parsers.py"), (parsers_edif, "parsers_edif.py")):
|
||||
path = Path(mod.__file__).resolve()
|
||||
assert path.name == name
|
||||
assert "src" in path.parts
|
||||
assert "Native Periscope overlay" not in path.read_text(encoding="utf-8")[:400]
|
||||
|
||||
|
||||
def test_pcb_parser_stays_native_kicad_pcb():
|
||||
path = Path(pcb.__file__).resolve()
|
||||
assert path.parts[-1] == "parsers_kicad_pcb.py"
|
||||
assert "src" in path.parts
|
||||
assert "_is_footprint_via" in path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_detect_format_negative_pcb_is_not_edif_or_kicad_sch():
|
||||
# A board file starts with (kicad_pcb …), not schematic markers.
|
||||
sample = "(kicad_pcb (version 20240108)\n"
|
||||
assert detect_netlist_format(sample) == "pads" # unknown schematic → PADS sniff default
|
||||
|
||||
|
||||
def test_parse_netlist_any_pads_roundtrip(tmp_path: Path):
|
||||
asc = tmp_path / "n.asc"
|
||||
asc.write_text(
|
||||
"*PADS-PCB*\n*PART*\nR1 0603\nU1 QFP48\n*NET*\n*SIGNAL* GND\nR1.1 U1.8\n*SIGNAL* 3V3\nU1.7\n*END*\n"
|
||||
)
|
||||
parts, nets, fmt = parse_netlist_any(asc)
|
||||
assert fmt == "pads"
|
||||
assert parts["R1"] == "0603"
|
||||
assert ("R1", "1") in nets["GND"]
|
||||
assert "GND" in nets
|
||||
Reference in New Issue
Block a user