diff options
author | jaseg <git@jaseg.de> | 2023-04-29 17:25:32 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-04-30 11:07:29 +0200 |
commit | 26c2460490b6e64790c94e00be848465a6a5fa96 (patch) | |
tree | c23288bc30772615a758a856a456cc1d74affb31 /gerbonara/excellon.py | |
parent | af3458b1e22f92f51606cff8f771d03551af4cc0 (diff) | |
download | gerbonara-26c2460490b6e64790c94e00be848465a6a5fa96.tar.gz gerbonara-26c2460490b6e64790c94e00be848465a6a5fa96.tar.bz2 gerbonara-26c2460490b6e64790c94e00be848465a6a5fa96.zip |
Fix remaining unit tests
Diffstat (limited to 'gerbonara/excellon.py')
-rwxr-xr-x | gerbonara/excellon.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/gerbonara/excellon.py b/gerbonara/excellon.py index d395ecf..9b75a69 100755 --- a/gerbonara/excellon.py +++ b/gerbonara/excellon.py @@ -46,8 +46,8 @@ class ExcellonContext: def select_tool(self, tool): """ Select the current tool. Retract drill first if necessary. """ - current_id = self.tools.get(id(self.current_tool)) - new_id = self.tools[id(tool)] + current_id = self.tools.get(self.current_tool) + new_id = self.tools[tool] if new_id != current_id: if self.drill_down: yield 'M16' # drill up @@ -270,17 +270,15 @@ class ExcellonFile(CamFile): def to_gerber(self, errros='raise'): """ Convert this excellon file into a :py:class:`~.rs274x.GerberFile`. """ - apertures = {} out = GerberFile() out.comments = self.comments + apertures = {} for obj in self.objects: - if id(obj.tool) not in apertures: - apertures[id(obj.tool)] = CircleAperture(obj.tool.diameter) - - out.objects.append(dataclasses.replace(obj, aperture=apertures[id(obj.tool)])) + if not (ap := apertures[obj.tool]): + ap = apertures[obj.tool] = CircleAperture(obj.tool.diameter) - out.apertures = list(apertures.values()) + out.objects.append(dataclasses.replace(obj, aperture=ap)) @property def generator(self): @@ -373,7 +371,7 @@ class ExcellonFile(CamFile): yield 'METRIC' if settings.unit == MM else 'INCH' # Build tool index - tool_map = { id(obj.tool): obj.tool for obj in self.objects } + tool_map = { obj.tool: obj.tool for obj in self.objects } tools = sorted(tool_map.items(), key=lambda id_tool: (id_tool[1].plated, id_tool[1].diameter)) mixed_plating = (len({ tool.plated for tool in tool_map.values() }) > 1) |