Skip to content

Commit

Permalink
[Diff][Fixed] The new logic to check for SCH/PCB
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Jan 9, 2024
1 parent 8bdf79d commit 9ea3e39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions kibot/out_any_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ 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:
# Use a temporary file
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':
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions kibot/out_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 9ea3e39

Please sign in to comment.