From 6c1ae59f2d589ffcac044ad5ddc8dfdf20b3b9b0 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 11 Feb 2026 12:33:40 +1300 Subject: [PATCH] Use .env or CLI for paths and options Co-authored-by: Cursor --- capacitors_by_net_pair.py | 3 +-- compare_protel_locations.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/capacitors_by_net_pair.py b/capacitors_by_net_pair.py index 0994cb5..d445693 100644 --- a/capacitors_by_net_pair.py +++ b/capacitors_by_net_pair.py @@ -4,8 +4,7 @@ Parse Protel PCB 2.8 ASCII (or Protel 99 SE PCB ASCII) and output capacitors by net pair: JSON with net pair as key, designator/value/package and total capacitance per net pair. -Input/output paths are read from .env (INPUT_FILE, OUTPUT_FILE) if set; -CLI arguments override them. +All paths: use .env (INPUT_FILE, OUTPUT_FILE) or CLI; CLI overrides .env. Usage: python capacitors_by_net_pair.py [file.pcb] [-o output.json] diff --git a/compare_protel_locations.py b/compare_protel_locations.py index 6646d00..f7e741b 100644 --- a/compare_protel_locations.py +++ b/compare_protel_locations.py @@ -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()