From 758991d75d36b7de63c24972c74a581db7795fbc Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 11 Feb 2026 12:36:14 +1300 Subject: [PATCH] Use outputs/ for all JSON output Co-authored-by: Cursor --- .env.example | 8 ++++---- .gitignore | 2 +- README.md | 12 ++++++------ capacitors_by_net_pair.py | 4 ++-- compare_protel_locations.py | 4 ++-- diff_spreadsheets.py | 2 +- find_bottom_termination_parts.py | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.env.example b/.env.example index cebeae2..08d0193 100644 --- a/.env.example +++ b/.env.example @@ -2,22 +2,22 @@ # Capacitors by net pair INPUT_FILE=board.pcb -OUTPUT_FILE=output/capacitors_by_net_pair.json +OUTPUT_FILE=outputs/capacitors_by_net_pair.json # Compare Protel locations FILE1=board_v1.pcb FILE2=board_v2.pcb -COMPARE_OUTPUT=output/compare_locations.json +COMPARE_OUTPUT=outputs/compare_locations.json THRESHOLD=1.0 # Spreadsheet diff (designator column, data from row 10) SHEET1=sheet1.xlsx SHEET2=sheet2.xlsx -DIFF_OUTPUT=output/spreadsheet_diff.json +DIFF_OUTPUT=outputs/spreadsheet_diff.json DESIGNATOR_COL=0 START_ROW=9 # Find bottom termination parts (search description column only; no package column) SHEET=sheet.xlsx -BOTTOM_TERM_OUTPUT=output/bottom_termination_parts.json +BOTTOM_TERM_OUTPUT=outputs/bottom_termination_parts.json DESCRIPTION_COL=1 diff --git a/.gitignore b/.gitignore index 52d21fc..30f5142 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.json .env -output/ +outputs/ diff --git a/README.md b/README.md index 585af92..afaeccb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Altium Scripts -**Convention:** All Python scripts use **.env** for input/output paths (and optional settings); you can override any value via **CLI**. Copy `.env.example` to `.env` and edit. +**Convention:** All Python scripts use **.env** for input/output paths (and optional settings); you can override any value via **CLI**. All scripts write JSON output to the **`outputs/`** folder by default. Copy `.env.example` to `.env` and edit. --- @@ -71,7 +71,7 @@ Finds all **two-pad components** on the PCB that share the same two nets (e.g. d python3 capacitors_by_net_pair.py board.PcbDoc -o out.json ``` - **Input/output from .env:** Copy `.env.example` to `.env` and set `INPUT_FILE` and `OUTPUT_FILE`. The script reads these when the optional `python-dotenv` package is installed; CLI arguments override them. Without `.env`, you can still pass the input file and `-o` on the command line. By default the JSON is written to **`output/capacitors_by_net_pair.json`** (the `output/` directory is created if needed). + **Input/output from .env:** Copy `.env.example` to `.env` and set `INPUT_FILE` and `OUTPUT_FILE`. The script reads these when the optional `python-dotenv` package is installed; CLI arguments override them. Without `.env`, you can still pass the input file and `-o` on the command line. By default the JSON is written to **`outputs/capacitors_by_net_pair.json`** (the `outputs/` directory is created if needed). See **`capacitors_by_net_pair.py`** for the script. It parses COMP/PATTERN/VALUE and NET/PIN data from the ASCII file and produces the same JSON shape as the DelphiScript. @@ -87,7 +87,7 @@ python3 capacitors_by_net_pair.py tests/sample_protel_ascii.pcb -o tests/out.jso **Script:** `compare_protel_locations.py` -Loads two Protel PCB 2.8 ASCII files and reports **which components have moved** between them. Component position is the centroid of pin coordinates. Output is written to `output/compare_locations.json` by default. +Loads two Protel PCB 2.8 ASCII files and reports **which components have moved** between them. Component position is the centroid of pin coordinates. Output is written to `outputs/compare_locations.json` by default. - **Moved:** designators with different (x, y) in file2, with old position, new position, and distance. - **Only in file1 / only in file2:** components that appear in just one file. @@ -96,7 +96,7 @@ Loads two Protel PCB 2.8 ASCII files and reports **which components have moved** ```bash python3 compare_protel_locations.py board_v1.pcb board_v2.pcb -python3 compare_protel_locations.py board_v1.pcb board_v2.pcb -o output/compare_locations.json +python3 compare_protel_locations.py board_v1.pcb board_v2.pcb -o outputs/compare_locations.json ``` Use **.env** (optional): set `FILE1`, `FILE2`, and `COMPARE_OUTPUT`; CLI arguments override them. Use `--threshold N` to set the minimum position change to count as moved (default 1.0). @@ -119,7 +119,7 @@ Compares two spreadsheets (`.xlsx` or `.csv`) on a designator column. Data is re ```bash pip install pandas openpyxl -python3 diff_spreadsheets.py sheet1.xlsx sheet2.xlsx -o output/spreadsheet_diff.json +python3 diff_spreadsheets.py sheet1.xlsx sheet2.xlsx -o outputs/spreadsheet_diff.json ``` Options: `--designator-col 0` (0-based column index), `--start-row 9` (0-based; 9 = row 10). Env: `SHEET1`, `SHEET2`, `DIFF_OUTPUT`. @@ -141,7 +141,7 @@ Reads the same spreadsheet format (designator column, data from row 10) plus **d - **Package types:** QFN, DFN, BGA, LGA, SON, MLF, MLP, WDFN, WQFN, VQFN, etc. - **Generic:** “bottom termination” (e.g. with 0201 or 0402) -Outputs matching designators, description, package, and the matched pattern to `output/bottom_termination_parts.json`. +Outputs matching designators, description, package, and the matched pattern to `outputs/bottom_termination_parts.json`. **Usage:** diff --git a/capacitors_by_net_pair.py b/capacitors_by_net_pair.py index d445693..08f81e9 100644 --- a/capacitors_by_net_pair.py +++ b/capacitors_by_net_pair.py @@ -187,7 +187,7 @@ def build_net_key(net1: str, net2: str) -> str: def main() -> int: default_input = os.environ.get("INPUT_FILE", "").strip() or None - default_output = os.environ.get("OUTPUT_FILE", "").strip() or "output/capacitors_by_net_pair.json" + default_output = os.environ.get("OUTPUT_FILE", "").strip() or "outputs/capacitors_by_net_pair.json" parser = argparse.ArgumentParser(description="List capacitors by net pair from Protel PCB 2.8 ASCII") parser.add_argument( @@ -199,7 +199,7 @@ def main() -> int: parser.add_argument( "-o", "--output", default=default_output, - help="Output JSON path (default: OUTPUT_FILE from .env or output/capacitors_by_net_pair.json)", + help="Output JSON path (default: OUTPUT_FILE from .env or outputs/capacitors_by_net_pair.json)", ) parser.add_argument("--all-two-pad", action="store_true", help="Include all 2-pad parts, not only C*") args = parser.parse_args() diff --git a/compare_protel_locations.py b/compare_protel_locations.py index f7e741b..43aba21 100644 --- a/compare_protel_locations.py +++ b/compare_protel_locations.py @@ -99,7 +99,7 @@ def main() -> int: default_file2 = os.environ.get("FILE2", "").strip() or None default_output = ( os.environ.get("COMPARE_OUTPUT", "").strip() - or "output/compare_locations.json" + or "outputs/compare_locations.json" ) default_threshold = os.environ.get("THRESHOLD", "").strip() try: @@ -126,7 +126,7 @@ def main() -> int: "-o", "--output", default=default_output, - help="Output JSON path (default: COMPARE_OUTPUT from .env or output/compare_locations.json)", + help="Output JSON path (default: COMPARE_OUTPUT from .env or outputs/compare_locations.json)", ) parser.add_argument( "--threshold", diff --git a/diff_spreadsheets.py b/diff_spreadsheets.py index 8d5553c..69f3635 100644 --- a/diff_spreadsheets.py +++ b/diff_spreadsheets.py @@ -57,7 +57,7 @@ def read_designators(path: str, designator_col: int = 0, start_row: int = 9) -> def main() -> int: default1 = os.environ.get("SHEET1", "").strip() or None default2 = os.environ.get("SHEET2", "").strip() or None - default_out = os.environ.get("DIFF_OUTPUT", "").strip() or "output/spreadsheet_diff.json" + default_out = os.environ.get("DIFF_OUTPUT", "").strip() or "outputs/spreadsheet_diff.json" default_col = os.environ.get("DESIGNATOR_COL", "").strip() default_start = os.environ.get("START_ROW", "").strip() try: diff --git a/find_bottom_termination_parts.py b/find_bottom_termination_parts.py index 9087186..eda0ba5 100644 --- a/find_bottom_termination_parts.py +++ b/find_bottom_termination_parts.py @@ -95,7 +95,7 @@ def is_bottom_termination_in_description(description: str) -> tuple[bool, str]: def main() -> int: default_sheet = os.environ.get("SHEET", "").strip() or None - default_out = os.environ.get("BOTTOM_TERM_OUTPUT", "").strip() or "output/bottom_termination_parts.json" + default_out = os.environ.get("BOTTOM_TERM_OUTPUT", "").strip() or "outputs/bottom_termination_parts.json" default_des_col = os.environ.get("DESCRIPTION_COL", "").strip() default_start = os.environ.get("START_ROW", "").strip() try: