From 26c2460490b6e64790c94e00be848465a6a5fa96 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 29 Apr 2023 17:25:32 +0200 Subject: Fix remaining unit tests --- gerbonara/excellon.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'gerbonara/excellon.py') 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) -- cgit