Use .env or CLI for paths and options

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-11 12:33:40 +13:00
parent ed5c186f4d
commit 6c1ae59f2d
2 changed files with 9 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
Load two Protel PCB 2.8 ASCII files and report which components have moved
between them. Component position is taken as the centroid of pin coordinates.
Input/output paths can be set in .env (FILE1, FILE2, COMPARE_OUTPUT); CLI overrides.
All paths: use .env (FILE1, FILE2, COMPARE_OUTPUT) or CLI; CLI overrides .env.
Usage:
python3 compare_protel_locations.py file1.pcb file2.pcb [-o report.json]
@@ -101,6 +101,11 @@ def main() -> int:
os.environ.get("COMPARE_OUTPUT", "").strip()
or "output/compare_locations.json"
)
default_threshold = os.environ.get("THRESHOLD", "").strip()
try:
default_threshold = float(default_threshold) if default_threshold else 1.0
except ValueError:
default_threshold = 1.0
parser = argparse.ArgumentParser(
description="Compare two Protel PCB ASCII files and list components that moved"
@@ -126,8 +131,8 @@ def main() -> int:
parser.add_argument(
"--threshold",
type=float,
default=1.0,
help="Minimum position change to count as moved (default: 1.0)",
default=default_threshold,
help="Minimum position change to count as moved (default: THRESHOLD from .env or 1.0)",
)
args = parser.parse_args()