refactor: extract schematic handlers into SchematicHandlersMixin
kicad_interface.py had grown to 8,596 lines. Most domains already delegate to classes in commands/, but the schematic domain (43 _handle_* methods + the schematic-only _svg_to_png helper, ~3,100 lines) was still inline. Move it into commands/schematic_handlers.py as SchematicHandlersMixin and have KiCADInterface inherit from it. Pure mechanical relocation — no logic change: - Methods stay bound to the same instance via the mixin, so every self.board, self._auto_save_board(), cross-handler call, and the command_routes table resolve exactly as before. - Verified all 159 functions/methods (116 kept + 43 moved + _svg_to_png) are AST-identical between the original and the split. - tests/test_sync_schematic_to_board_footprints.py patch targets updated to follow the moved module (commands.schematic_handlers.pcbnew). - Full suite at the exact current main baseline (8 failed / 1044 passed; the 8 are the pre-existing Java-not-installed freerouting/autoroute set). Regenerated against main after the June merge wave (#226-229, #231-234, #238, #252, #253); deliberately excludes the 19 _handle_export_* kicad-cli handlers from #253 and the datasheet delegators.
This commit is contained in:
3104
python/commands/schematic_handlers.py
Normal file
3104
python/commands/schematic_handlers.py
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,7 @@ class TestAddMissingFootprintsFromSchematic:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
patch("kicad_interface.pcbnew") as mock_pcbnew,
|
patch("commands.schematic_handlers.pcbnew") as mock_pcbnew,
|
||||||
patch("commands.library.LibraryManager") as mock_lm_cls,
|
patch("commands.library.LibraryManager") as mock_lm_cls,
|
||||||
):
|
):
|
||||||
mock_pcbnew.FootprintLoad.return_value = loaded_module
|
mock_pcbnew.FootprintLoad.return_value = loaded_module
|
||||||
@@ -113,7 +113,7 @@ class TestAddMissingFootprintsFromSchematic:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
patch("kicad_interface.pcbnew"),
|
patch("commands.schematic_handlers.pcbnew"),
|
||||||
patch("commands.library.LibraryManager") as mock_lm_cls,
|
patch("commands.library.LibraryManager") as mock_lm_cls,
|
||||||
):
|
):
|
||||||
lm = MagicMock()
|
lm = MagicMock()
|
||||||
@@ -144,7 +144,7 @@ class TestAddMissingFootprintsFromSchematic:
|
|||||||
{"reference": "#FLG0001", "value": "PWR_FLAG", "footprint": ""},
|
{"reference": "#FLG0001", "value": "PWR_FLAG", "footprint": ""},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
patch("kicad_interface.pcbnew"),
|
patch("commands.schematic_handlers.pcbnew"),
|
||||||
patch("commands.library.LibraryManager") as mock_lm_cls,
|
patch("commands.library.LibraryManager") as mock_lm_cls,
|
||||||
):
|
):
|
||||||
mock_lm_cls.return_value = MagicMock(libraries={})
|
mock_lm_cls.return_value = MagicMock(libraries={})
|
||||||
@@ -172,7 +172,7 @@ class TestAddMissingFootprintsFromSchematic:
|
|||||||
"_extract_components_from_schematic",
|
"_extract_components_from_schematic",
|
||||||
return_value=[{"reference": "R1", "value": "10k", "footprint": ""}],
|
return_value=[{"reference": "R1", "value": "10k", "footprint": ""}],
|
||||||
),
|
),
|
||||||
patch("kicad_interface.pcbnew"),
|
patch("commands.schematic_handlers.pcbnew"),
|
||||||
patch("commands.library.LibraryManager") as mock_lm_cls,
|
patch("commands.library.LibraryManager") as mock_lm_cls,
|
||||||
):
|
):
|
||||||
mock_lm_cls.return_value = MagicMock(libraries={})
|
mock_lm_cls.return_value = MagicMock(libraries={})
|
||||||
@@ -205,7 +205,7 @@ class TestAddMissingFootprintsFromSchematic:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
patch("kicad_interface.pcbnew"),
|
patch("commands.schematic_handlers.pcbnew"),
|
||||||
patch("commands.library.LibraryManager") as mock_lm_cls,
|
patch("commands.library.LibraryManager") as mock_lm_cls,
|
||||||
):
|
):
|
||||||
mock_lm_cls.return_value = MagicMock(libraries={}) # MyVendor not present
|
mock_lm_cls.return_value = MagicMock(libraries={}) # MyVendor not present
|
||||||
|
|||||||
Reference in New Issue
Block a user