diff --git a/kibot/out_any_diff.py b/kibot/out_any_diff.py index 459d55cf..d7695d58 100644 --- a/kibot/out_any_diff.py +++ b/kibot/out_any_diff.py @@ -68,7 +68,6 @@ def remove_git_worktree(self, name): self.run_git(['worktree', 'remove', '--force', name]) def write_empty_file(self, name, create_tmp=False): - to_remove = [name] base, ext = os.path.splitext(name) kind = 'PCB' if ext == '.kicad_pcb' else 'schematic' if create_tmp: @@ -76,6 +75,7 @@ def write_empty_file(self, name, create_tmp=False): with NamedTemporaryFile(mode='w', suffix=ext, delete=False) as f: name = f.name base = os.path.splitext(name)[0] + to_remove = [name] logger.debug('Creating empty '+kind+': '+name) with open(name, 'w') as f: if ext == '.kicad_sch': @@ -94,7 +94,7 @@ def write_empty_file(self, name, create_tmp=False): with open(lib_name, 'w') as f: f.write("EESchema-LIBRARY Version 2.4\n#\n#End Library\n") to_remove.append(lib_name) - return to_remove + return name, to_remove def save_layers_incl(self, layers): self._solved_layers = layers diff --git a/kibot/out_diff.py b/kibot/out_diff.py index 17572262..df696aa2 100644 --- a/kibot/out_diff.py +++ b/kibot/out_diff.py @@ -149,7 +149,8 @@ def cache_pcb(self, name, force_exist): if not os.path.isfile(name): if self.always_fail_if_missing: raise KiPlotConfigurationError('Missing file to compare: `{}`'.format(name)) - self._to_remove.extend(self.write_empty_file(name, create_tmp=True)) + name, to_remove = self.write_empty_file(name, create_tmp=True) + self._to_remove.extend(to_remove) hash = self.get_digest(name) self.add_to_cache(name, hash) return hash @@ -164,7 +165,8 @@ def cache_sch(self, name, force_exist): if not os.path.isfile(name): if self.always_fail_if_missing: raise KiPlotConfigurationError('Missing file to compare: `{}`'.format(name)) - self._to_remove.extend(self.write_empty_file(name, create_tmp=True)) + name, to_remove = self.write_empty_file(name, create_tmp=True) + self._to_remove.extend(to_remove) # Schematics can have sub-sheets sch = load_any_sch(name, os.path.splitext(os.path.basename(name))[0]) files = sch.get_files()