boardwright 0.8.2__tar.gz → 0.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. {boardwright-0.8.2 → boardwright-0.8.3}/CHANGELOG.md +16 -1
  2. {boardwright-0.8.2 → boardwright-0.8.3}/PKG-INFO +1 -1
  3. {boardwright-0.8.2 → boardwright-0.8.3}/pyproject.toml +1 -1
  4. boardwright-0.8.3/src/boardwright/__init__.py +1 -0
  5. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/sch.py +9 -2
  6. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/update.py +35 -1
  7. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_sch_add.py +37 -0
  8. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_update.py +62 -0
  9. boardwright-0.8.2/src/boardwright/__init__.py +0 -1
  10. {boardwright-0.8.2 → boardwright-0.8.3}/.gitignore +0 -0
  11. {boardwright-0.8.2 → boardwright-0.8.3}/LICENSE +0 -0
  12. {boardwright-0.8.2 → boardwright-0.8.3}/README.md +0 -0
  13. {boardwright-0.8.2 → boardwright-0.8.3}/docs/devlog/README.md +0 -0
  14. {boardwright-0.8.2 → boardwright-0.8.3}/examples/existing/README.md +0 -0
  15. {boardwright-0.8.2 → boardwright-0.8.3}/examples/libs/customlib/README.md +0 -0
  16. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/__main__.py +0 -0
  17. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/board.py +0 -0
  18. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/build.py +0 -0
  19. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/check.py +0 -0
  20. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/circuit.py +0 -0
  21. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/cli.py +0 -0
  22. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/copper.py +0 -0
  23. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/dsn.py +0 -0
  24. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/edits.py +0 -0
  25. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/env.py +0 -0
  26. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/errors.py +0 -0
  27. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/existing.py +0 -0
  28. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/live.py +0 -0
  29. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/model.py +0 -0
  30. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/pins.py +0 -0
  31. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/placement.py +0 -0
  32. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/preview.py +0 -0
  33. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/project.py +0 -0
  34. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/review.py +0 -0
  35. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/route.py +0 -0
  36. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/selection.py +0 -0
  37. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/ses.py +0 -0
  38. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/si.py +0 -0
  39. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/silk.py +0 -0
  40. {boardwright-0.8.2 → boardwright-0.8.3}/src/boardwright/verify.py +0 -0
  41. {boardwright-0.8.2 → boardwright-0.8.3}/tests/conftest.py +0 -0
  42. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/customlib_test.kicad_pcb +0 -0
  43. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/esp32c3_min.kicad_pcb +0 -0
  44. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/ldo_breakout.kicad_pcb +0 -0
  45. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/rp2040_min.kicad_pcb +0 -0
  46. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/stm32f103_4l.kicad_pcb +0 -0
  47. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/stm32f103_min.kicad_pcb +0 -0
  48. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/create_golden/tps54202_buck.kicad_pcb +0 -0
  49. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/customlib_test.dsn +0 -0
  50. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/customlib_test.kicad_pcb +0 -0
  51. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/customlib_test.kicad_pro +0 -0
  52. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min.dsn +0 -0
  53. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min.kicad_pcb +0 -0
  54. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min.kicad_pro +0 -0
  55. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min_back.dsn +0 -0
  56. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min_back.kicad_pcb +0 -0
  57. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/esp32c3_min_back.kicad_pro +0 -0
  58. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_arcs.dsn +0 -0
  59. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_arcs.kicad_pcb +0 -0
  60. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_arcs.kicad_pro +0 -0
  61. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_breakout.dsn +0 -0
  62. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_breakout.kicad_pcb +0 -0
  63. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/ldo_breakout.kicad_pro +0 -0
  64. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/rp2040_min.dsn +0 -0
  65. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/rp2040_min.kicad_pcb +0 -0
  66. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/rp2040_min.kicad_pro +0 -0
  67. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_4l.dsn +0 -0
  68. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_4l.kicad_pcb +0 -0
  69. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_4l.kicad_pro +0 -0
  70. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_min.dsn +0 -0
  71. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_min.kicad_pcb +0 -0
  72. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/stm32f103_min.kicad_pro +0 -0
  73. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_buck.dsn +0 -0
  74. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_buck.kicad_pcb +0 -0
  75. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_buck.kicad_pro +0 -0
  76. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_routed.dsn +0 -0
  77. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_routed.kicad_pcb +0 -0
  78. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/dsn/tps54202_routed.kicad_pro +0 -0
  79. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ldo_r50.net +0 -0
  80. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/live_unsaved/r1_moved.kicad_pcb.txt +0 -0
  81. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/live_unsaved/untouched.kicad_pcb.txt +0 -0
  82. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/customlib_test.kicad_pcb +0 -0
  83. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/customlib_test.kicad_sch.sha256 +0 -0
  84. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min.kicad_pcb +0 -0
  85. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min.kicad_sch.sha256 +0 -0
  86. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min_u1_r90.kicad_pcb +0 -0
  87. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min_u1_r90.kicad_sch.sha256 +0 -0
  88. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min_u1_r90_back.kicad_pcb +0 -0
  89. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/esp32c3_min_u1_r90_back.kicad_sch.sha256 +0 -0
  90. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/ldo_breakout.kicad_pcb +0 -0
  91. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/ldo_breakout.kicad_sch.sha256 +0 -0
  92. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/rp2040_min.kicad_pcb +0 -0
  93. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/rp2040_min.kicad_sch.sha256 +0 -0
  94. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/stm32f103_4l.kicad_pcb +0 -0
  95. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/stm32f103_4l.kicad_sch.sha256 +0 -0
  96. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/stm32f103_min.kicad_pcb +0 -0
  97. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/stm32f103_min.kicad_sch.sha256 +0 -0
  98. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/tps54202_buck.kicad_pcb +0 -0
  99. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/place_golden/tps54202_buck.kicad_sch.sha256 +0 -0
  100. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/reader/cheapino_kicad8.NOTICE +0 -0
  101. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/reader/cheapino_kicad8.kicad_pcb +0 -0
  102. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/reader/demos.json +0 -0
  103. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/reader/golden.json +0 -0
  104. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/reader/kicad_tools_moves.json +0 -0
  105. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/customlib_test.kicad_sch +0 -0
  106. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/esp32c3_min.kicad_sch +0 -0
  107. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/ldo_breakout.kicad_sch +0 -0
  108. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/rp2040_min.kicad_sch +0 -0
  109. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/stm32f103_4l.kicad_sch +0 -0
  110. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/stm32f103_min.kicad_sch +0 -0
  111. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/schematic_golden/tps54202_buck.kicad_sch +0 -0
  112. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/esp32c3_min.golden.kicad_pcb +0 -0
  113. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/esp32c3_min.kicad_pcb +0 -0
  114. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/esp32c3_min.ses +0 -0
  115. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_breakout.golden.kicad_pcb +0 -0
  116. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_breakout.kicad_pcb +0 -0
  117. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_breakout.ses +0 -0
  118. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_routed.golden.kicad_pcb +0 -0
  119. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_routed.kicad_pcb +0 -0
  120. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_routed.ses +0 -0
  121. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_stubs.golden.kicad_pcb +0 -0
  122. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_stubs.kicad_pcb +0 -0
  123. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/ldo_stubs.ses +0 -0
  124. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/stm32f103_4l.golden.kicad_pcb +0 -0
  125. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/stm32f103_4l.kicad_pcb +0 -0
  126. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/stm32f103_4l.ses +0 -0
  127. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/tps54202_buck.golden.kicad_pcb +0 -0
  128. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/tps54202_buck.kicad_pcb +0 -0
  129. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/ses/tps54202_buck.ses +0 -0
  130. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/customlib_test.kicad_pcb +0 -0
  131. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/esp32c3_min.kicad_pcb +0 -0
  132. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/golden.json +0 -0
  133. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/ldo_breakout.kicad_pcb +0 -0
  134. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/rp2040_min.kicad_pcb +0 -0
  135. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/stm32f103_4l.kicad_pcb +0 -0
  136. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/stm32f103_min.kicad_pcb +0 -0
  137. {boardwright-0.8.2 → boardwright-0.8.3}/tests/data/silk_refs/tps54202_buck.kicad_pcb +0 -0
  138. {boardwright-0.8.2 → boardwright-0.8.3}/tests/reader_dump.py +0 -0
  139. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_board_model.py +0 -0
  140. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_board_reader.py +0 -0
  141. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_clearance.py +0 -0
  142. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_create_golden.py +0 -0
  143. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_dsn_export.py +0 -0
  144. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_edit_route.py +0 -0
  145. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_env_kicad_cli.py +0 -0
  146. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_env_pcbnew.py +0 -0
  147. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_library_scope.py +0 -0
  148. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_live.py +0 -0
  149. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_live_unsaved.py +0 -0
  150. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_open_in_kicad.py +0 -0
  151. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_pipeline.py +0 -0
  152. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_place_golden.py +0 -0
  153. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_remove.py +0 -0
  154. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_sch_cli.py +0 -0
  155. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_sch_repoint.py +0 -0
  156. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_sch_subsheet.py +0 -0
  157. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_schematic_golden.py +0 -0
  158. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_ses_import.py +0 -0
  159. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_si.py +0 -0
  160. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_silk_refs.py +0 -0
  161. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_unwritable_output.py +0 -0
  162. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_verify_existing.py +0 -0
  163. {boardwright-0.8.2 → boardwright-0.8.3}/tests/test_workflows.py +0 -0
@@ -7,6 +7,20 @@ the command line).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.3] - 2026-11-20
11
+
12
+ ### Fixed
13
+
14
+ - `existing update` sets or clears each footprint's `dnp` and
15
+ `exclude_from_bom` attributes from its symbol, as KiCad's Update PCB does,
16
+ leaving its other attributes as they are. They were never read, so KiCad's
17
+ schematic parity check reported "'Do not populate' settings differ" and
18
+ "'Exclude from bill of materials' settings differ" (#98).
19
+ - `sch add` with a library symbol no longer stops with a traceback (exit 2)
20
+ when the sheet's first placed part has no pins: it takes its pin format
21
+ from a part that has one. A sheet with none refuses the library part with a
22
+ message (exit 1); copying an existing part still works there (#99).
23
+
10
24
  ## [0.8.2] - 2026-11-20
11
25
 
12
26
  ### Fixed
@@ -357,7 +371,8 @@ First public release.
357
371
  - `boardwright impedance` (IPC-2141 closed form) and `doctor`.
358
372
  - Seven example boards and specs for KiCad's own demo projects.
359
373
 
360
- [Unreleased]: https://github.com/heibench/boardwright/compare/v0.8.2...HEAD
374
+ [Unreleased]: https://github.com/heibench/boardwright/compare/v0.8.3...HEAD
375
+ [0.8.3]: https://github.com/heibench/boardwright/compare/v0.8.2...v0.8.3
361
376
  [0.8.2]: https://github.com/heibench/boardwright/compare/v0.8.1...v0.8.2
362
377
  [0.8.1]: https://github.com/heibench/boardwright/compare/v0.8.0...v0.8.1
363
378
  [0.8.0]: https://github.com/heibench/boardwright/compare/v0.7.0...v0.8.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: boardwright
3
- Version: 0.8.2
3
+ Version: 0.8.3
4
4
  Summary: Generate and edit KiCad boards and schematics from a short Python description, checked by KiCad itself.
5
5
  Project-URL: Homepage, https://github.com/heibench/boardwright
6
6
  Project-URL: Documentation, https://heibench.com/boardwright/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "boardwright"
3
- version = "0.8.2"
3
+ version = "0.8.3"
4
4
  description = "Generate and edit KiCad boards and schematics from a short Python description, checked by KiCad itself."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -0,0 +1 @@
1
+ __version__ = "0.8.3"
@@ -368,7 +368,11 @@ def _from_library(template: str, body: str, lib_id: str, x: float, y: float) ->
368
368
  t = _fresh(template)
369
369
  p0 = re.search(r"\n\t\t\(property ", t)
370
370
  i0 = re.search(r"\n\t\t\(instances\b", t)
371
- pin_tpl = next(t[s:e] for s, e in blocks(t, ("pin",)))
371
+ pins_ = blocks(t, ("pin",))
372
+ if not pins_:
373
+ raise SystemExit(f"no placed part on the sheet has a pin to take the file's format from; "
374
+ f"add {lib_id} in KiCad, or name an existing part to copy (#99)")
375
+ pin_tpl = t[pins_[0][0]:pins_[0][1]]
372
376
  head, tail = t[:p0.start()], t[i0.start():]
373
377
  head = re.sub(r'\(lib_id "[^"]*"\)', f'(lib_id "{lib_id}")', head, count=1)
374
378
  head = re.sub(r"\n\t\t\(lib_name \"[^\"]*\"\)", "", head)
@@ -465,7 +469,10 @@ def add(d: Path, spec_path: str) -> int:
465
469
  glabel_t, hlabel_t = first("global_label", [t, *rest]), first("hierarchical_label", [t])
466
470
  if wire_t is None or (label_t is None and glabel_t is None):
467
471
  raise SystemExit("the project has no wire or no label to take the file's format from")
468
- template = next((b for b in here if not (prop(b, "Reference") or "#").startswith("#")), None)
472
+ parts = [b for b in here if not (prop(b, "Reference") or "#").startswith("#")]
473
+ # a part with a pin, which a symbol added from the library copies its pin lines from (#99);
474
+ # any part carries the sheet's instance path
475
+ template = next((b for b in parts if blocks(b, ("pin",))), parts[0] if parts else None)
469
476
  if template is None:
470
477
  raise SystemExit(f"{sh.path.name} has no placed part to take its format and hierarchy path from; add one in KiCad first")
471
478
  path = _instance_path(template)
@@ -78,6 +78,7 @@ def read_netlist(path: Path) -> tuple[dict, dict]:
78
78
  "ref": _str(c, "ref"), "value": _str(c, "value") or "", "footprint": _str(c, "footprint") or "",
79
79
  "sheetname": re.sub(r"\\(.)", r"\1", sp.group(1)), "sheetfile": props.get("Sheetfile", ""),
80
80
  "skip": "exclude_from_board" in props, "fields": fields,
81
+ "dnp": "dnp" in props, "exclude_from_bom": "exclude_from_bom" in props,
81
82
  }
82
83
  pins = {}
83
84
  for s, e in blocks(text, ("net",)):
@@ -127,6 +128,36 @@ def with_fields(fp: str, fields: dict[str, str]) -> tuple[str, list[str]]:
127
128
  return fp, changed
128
129
 
129
130
 
131
+ # The order KiCad 10 writes a footprint's (attr ...) tokens in.
132
+ _ATTR_ORDER = ("smd", "through_hole", "board_only", "exclude_from_pos_files", "exclude_from_bom",
133
+ "allow_missing_courtyard", "dnp", "allow_soldermask_bridges")
134
+
135
+
136
+ def with_flags(fp: str, sym: dict) -> tuple[str, list[str]]:
137
+ """The board footprint with its symbol's "Do not populate" and "Exclude
138
+ from bill of materials" flags in its (attr ...), as KiCad's Update PCB
139
+ sets them; its other attributes are left as they are (#98). Returns the
140
+ block and what changed, e.g. ["dnp set"]."""
141
+ m = re.search(r"\n\t\t\(attr((?: [a-z_]+)*)\)", fp)
142
+ have = m.group(1).split() if m else []
143
+ want = [a for a in have if a not in ("dnp", "exclude_from_bom")] + [a for a in ("dnp", "exclude_from_bom") if sym[a]]
144
+ want.sort(key=lambda a: _ATTR_ORDER.index(a) if a in _ATTR_ORDER else len(_ATTR_ORDER))
145
+ if want == have:
146
+ return fp, []
147
+ changed = [f"{a} {'set' if sym[a] else 'cleared'}" for a in ("dnp", "exclude_from_bom") if (a in have) != sym[a]]
148
+ line = f"\n\t\t(attr {' '.join(want)})" if want else ""
149
+ if m:
150
+ return fp[:m.start()] + line + fp[m.end():], changed
151
+ k = max((e for s, e in blocks(fp, ("property",)) if fp[s:s + 13] == "\n\t\t(property "), default=None)
152
+ for key in ("path", "sheetname", "sheetfile"):
153
+ km = re.search(r'\n\t\t\(%s "[^"]*"\)' % key, fp)
154
+ if km:
155
+ k = km.end()
156
+ if k is None:
157
+ k = fp.index("\n", fp.index("\n\t\t(at "))
158
+ return fp[:k] + line + fp[k:], changed
159
+
160
+
130
161
  def _footprints(t: str) -> list[tuple[int, int]]:
131
162
  return [(s, e) for s, e in blocks(t, ("footprint",)) if t[s:s + 13] == "\n\t(footprint "]
132
163
 
@@ -460,6 +491,9 @@ def update(d: Path, pcb: Path, netlist: str | None = None, body: str = "keep") -
460
491
  new, fields = with_fields(new, c["fields"])
461
492
  if fields:
462
493
  notes.append(f"{c['ref']}: {', '.join(fields)} from the symbol")
494
+ new, flags = with_flags(new, c)
495
+ if flags:
496
+ notes.append(f"{c['ref']}: {', '.join(flags)}")
463
497
  for _s, _e, num, have in _pads(new):
464
498
  if num in want and want[num] != have:
465
499
  notes.append(f"{c['ref']}.{num}: net {have or '(none)'} -> {want[num]}")
@@ -482,7 +516,7 @@ def update(d: Path, pcb: Path, netlist: str | None = None, body: str = "keep") -
482
516
  text = mod.read_text()
483
517
  ex0, ey0, ex1, ey1 = _extent(text)
484
518
  fx, fy = round(x - ex0, 2), round(y - ey0, 2)
485
- made.append(with_fields(new_footprint(text, c["footprint"], c, path, fx, fy, want), c["fields"])[0])
519
+ made.append(with_flags(with_fields(new_footprint(text, c["footprint"], c, path, fx, fy, want), c["fields"])[0], c)[0])
486
520
  print(f"{c['ref']}: added {c['footprint']} at ({fx:g}, {fy:g}), beside the board: place it")
487
521
  y += ey1 - ey0 + 2.54
488
522
  row = max(row, ex1 - ex0)
@@ -223,3 +223,40 @@ def test_a_project_row_naming_the_stock_folder_is_found(tmp_path, monkeypatch, k
223
223
  (d / table).write_text(f'({table.replace("-", "_")}\n (version 7)\n'
224
224
  f' (lib (name "{nick}")(type "KiCad")(uri "${{{var}}}/{lib}")(options "")(descr ""))\n)\n')
225
225
  assert sch._in_table(d / table, nick, d, kind=kind) == (True, stock / lib)
226
+
227
+
228
+ def _strip_pins(f, refs):
229
+ """The sheet with the placed parts `refs` written without (pin ...) lines,
230
+ as a part with no pins (a mounting hole, a logo) is."""
231
+ t = f.read_text()
232
+ for s, e in reversed(sch.Sheet(f).instances()):
233
+ if sch.prop(t[s:e], "Reference") in refs:
234
+ t = t[:s] + re.sub(r'\n\t\t\(pin "[^"]*" \(uuid "[^"]*"\)\n\t\t\)', "", t[s:e]) + t[e:]
235
+ f.write_text(t)
236
+
237
+
238
+ def test_a_library_part_is_added_when_the_first_part_has_no_pins(proj, tmp_path):
239
+ """#99: add took its pin lines from the sheet's first placed part, J1 here,
240
+ and crashed (StopIteration, exit 2) when it had none."""
241
+ _strip_pins(proj / SCH, {"J1"})
242
+ assert main(["sch", str(proj), "add", _spec(tmp_path, [R50])]) == 0
243
+ after = (proj / SCH).read_text()
244
+ part = next(after[s:e] for s, e in sch.Sheet(proj / SCH).instances() if '(lib_id "Mine:R_new")' in after[s:e])
245
+ assert sorted(re.findall(r'\(pin "([^"]*)"', part)) == ["1", "2"]
246
+
247
+
248
+ def test_a_sheet_with_no_pinned_part_refuses_a_library_part_with_a_message(proj, tmp_path, capsys):
249
+ f = proj / SCH
250
+ _strip_pins(f, {sch.prop(f.read_text()[s:e], "Reference") for s, e in sch.Sheet(f).instances()})
251
+ before = f.read_text()
252
+ assert main(["sch", str(proj), "add", _spec(tmp_path, [R50])]) == 1
253
+ assert "no placed part on the sheet has a pin" in capsys.readouterr().err
254
+ assert f.read_text() == before
255
+
256
+
257
+ def test_a_sheet_with_no_pinned_part_still_copies_an_existing_part(proj, tmp_path):
258
+ f = proj / SCH
259
+ _strip_pins(f, {sch.prop(f.read_text()[s:e], "Reference") for s, e in sch.Sheet(f).instances()})
260
+ assert main(["sch", str(proj), "add", _spec(tmp_path, [("R51", "R1", "2k", "Resistor_SMD:R_0805_2012Metric",
261
+ {1: "+3V3", 2: "GND"})])]) == 0
262
+ assert '(reference "R51")' in f.read_text()
@@ -475,3 +475,65 @@ def test_kicad_finds_no_field_mismatch_after_an_update(ldo, tmp_path):
475
475
  assert before == {"footprint_symbol_field_mismatch", "missing_footprint"}
476
476
  assert main(["existing", str(ldo), "update"]) == 0
477
477
  assert _gate(ldo, tmp_path, "after")["schematic_parity"] == []
478
+
479
+
480
+ def _with_flag(text: str, ref: str, flag: str) -> str:
481
+ """NET with `ref` carrying the component property `flag` (dnp,
482
+ exclude_from_bom), in the form KiCad 10.0.8 writes it."""
483
+ i = text.index(f'(ref "{ref}")')
484
+ j = text.index('\t\t\t(property\n\t\t\t\t(name "Sheetname")', i)
485
+ return text[:j] + f'\t\t\t(property\n\t\t\t\t(name "{flag}")\n\t\t\t)\n' + text[j:]
486
+
487
+
488
+ def test_update_carries_dnp_and_exclude_from_bom_onto_the_footprint(ldo, tmp_path, capsys):
489
+ """KiCad's parity check flags a footprint whose "Do not populate" or
490
+ "Exclude from bill of materials" differs from its symbol's (#98). Set,
491
+ then a second run changes nothing, then cleared in the schematic."""
492
+ _unlink(ldo)
493
+ text = _with_flag(_with_flag(NET.read_text(), "C1", "dnp"), "R1", "exclude_from_bom")
494
+ f = tmp_path / "flags.net"
495
+ f.write_text(text)
496
+ board = ldo / "ldo_breakout.kicad_pcb"
497
+ assert main(["existing", str(ldo), "update", str(f)]) == 0
498
+ out = capsys.readouterr().out
499
+ assert "C1: dnp set" in out and "R1: exclude_from_bom set" in out
500
+ new = board.read_text()
501
+ fp = {update._prop(new[s:e], "Reference"): new[s:e] for s, e in update._footprints(new)}
502
+ assert "\n\t\t(attr smd dnp)\n" in fp["C1"] and "\n\t\t(attr smd exclude_from_bom)\n" in fp["R1"]
503
+ assert "\n\t\t(attr smd)\n" in fp["D1"]
504
+ assert main(["existing", str(ldo), "update", str(f)]) == 0
505
+ assert board.read_text() == new
506
+ assert main(["existing", str(ldo), "update", str(NET)]) == 0
507
+ out = capsys.readouterr().out
508
+ assert "C1: dnp cleared" in out and "R1: exclude_from_bom cleared" in out
509
+ assert "(attr smd dnp)" not in board.read_text() and "exclude_from_bom)" not in board.read_text()
510
+
511
+
512
+ @pytest.mark.parametrize("attr, sym, want", [
513
+ ("(attr through_hole)", {"dnp": True, "exclude_from_bom": True}, "(attr through_hole exclude_from_bom dnp)"),
514
+ ("(attr exclude_from_pos_files exclude_from_bom)", {"dnp": False, "exclude_from_bom": False},
515
+ "(attr exclude_from_pos_files)"),
516
+ ("(attr smd allow_missing_courtyard)", {"dnp": True, "exclude_from_bom": False}, "(attr smd allow_missing_courtyard dnp)"),
517
+ ])
518
+ def test_flags_keep_the_other_attributes_in_kicads_order(attr, sym, want):
519
+ fp = f'\n\t(footprint "X"\n\t\t(at 1 2)\n\t\t{attr}\n\t)'
520
+ assert update.with_flags(fp, sym)[0] == f'\n\t(footprint "X"\n\t\t(at 1 2)\n\t\t{want}\n\t)'
521
+
522
+
523
+ def test_a_footprint_without_attr_gets_one_after_its_link():
524
+ fp = '\n\t(footprint "X"\n\t\t(at 1 2)\n\t\t(property "Reference" "X1"\n\t\t)\n\t\t(path "/a")\n\t\t(sheetfile "x.kicad_sch")\n\t)'
525
+ new, changed = update.with_flags(fp, {"dnp": True, "exclude_from_bom": False})
526
+ assert changed == ["dnp set"] and '(sheetfile "x.kicad_sch")\n\t\t(attr dnp)\n\t)' in new
527
+
528
+
529
+ @pytest.mark.kicad
530
+ @needs_kicad
531
+ def test_kicad_finds_no_flag_mismatch_after_an_update(ldo, tmp_path):
532
+ """#98: D1 set do-not-populate and R1 left out of the BOM in the schematic.
533
+ KiCad's parity check flags both before the update and neither after."""
534
+ assert main(["sch", str(ldo), "set", "D1", "dnp=yes"]) == 0
535
+ assert main(["sch", str(ldo), "set", "R1", "in_bom=no"]) == 0
536
+ before = [v["description"] for v in _gate(ldo, tmp_path, "before")["schematic_parity"]]
537
+ assert len(before) == 2 and all("settings differ" in d for d in before)
538
+ assert main(["existing", str(ldo), "update"]) == 0
539
+ assert _gate(ldo, tmp_path, "after")["schematic_parity"] == []
@@ -1 +0,0 @@
1
- __version__ = "0.8.2"
File without changes
File without changes
File without changes