[Diff][Fixed] The new logic to check for SCH/PCB
This commit is contained in:
parent
8bdf79d8c8
commit
9ea3e39481
|
|
@ -68,7 +68,6 @@ class AnyDiffOptions(VariantOptions):
|
||||||
self.run_git(['worktree', 'remove', '--force', name])
|
self.run_git(['worktree', 'remove', '--force', name])
|
||||||
|
|
||||||
def write_empty_file(self, name, create_tmp=False):
|
def write_empty_file(self, name, create_tmp=False):
|
||||||
to_remove = [name]
|
|
||||||
base, ext = os.path.splitext(name)
|
base, ext = os.path.splitext(name)
|
||||||
kind = 'PCB' if ext == '.kicad_pcb' else 'schematic'
|
kind = 'PCB' if ext == '.kicad_pcb' else 'schematic'
|
||||||
if create_tmp:
|
if create_tmp:
|
||||||
|
|
@ -76,6 +75,7 @@ class AnyDiffOptions(VariantOptions):
|
||||||
with NamedTemporaryFile(mode='w', suffix=ext, delete=False) as f:
|
with NamedTemporaryFile(mode='w', suffix=ext, delete=False) as f:
|
||||||
name = f.name
|
name = f.name
|
||||||
base = os.path.splitext(name)[0]
|
base = os.path.splitext(name)[0]
|
||||||
|
to_remove = [name]
|
||||||
logger.debug('Creating empty '+kind+': '+name)
|
logger.debug('Creating empty '+kind+': '+name)
|
||||||
with open(name, 'w') as f:
|
with open(name, 'w') as f:
|
||||||
if ext == '.kicad_sch':
|
if ext == '.kicad_sch':
|
||||||
|
|
@ -94,7 +94,7 @@ class AnyDiffOptions(VariantOptions):
|
||||||
with open(lib_name, 'w') as f:
|
with open(lib_name, 'w') as f:
|
||||||
f.write("EESchema-LIBRARY Version 2.4\n#\n#End Library\n")
|
f.write("EESchema-LIBRARY Version 2.4\n#\n#End Library\n")
|
||||||
to_remove.append(lib_name)
|
to_remove.append(lib_name)
|
||||||
return to_remove
|
return name, to_remove
|
||||||
|
|
||||||
def save_layers_incl(self, layers):
|
def save_layers_incl(self, layers):
|
||||||
self._solved_layers = layers
|
self._solved_layers = layers
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,8 @@ class DiffOptions(AnyDiffOptions):
|
||||||
if not os.path.isfile(name):
|
if not os.path.isfile(name):
|
||||||
if self.always_fail_if_missing:
|
if self.always_fail_if_missing:
|
||||||
raise KiPlotConfigurationError('Missing file to compare: `{}`'.format(name))
|
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)
|
hash = self.get_digest(name)
|
||||||
self.add_to_cache(name, hash)
|
self.add_to_cache(name, hash)
|
||||||
return hash
|
return hash
|
||||||
|
|
@ -164,7 +165,8 @@ class DiffOptions(AnyDiffOptions):
|
||||||
if not os.path.isfile(name):
|
if not os.path.isfile(name):
|
||||||
if self.always_fail_if_missing:
|
if self.always_fail_if_missing:
|
||||||
raise KiPlotConfigurationError('Missing file to compare: `{}`'.format(name))
|
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
|
# Schematics can have sub-sheets
|
||||||
sch = load_any_sch(name, os.path.splitext(os.path.basename(name))[0])
|
sch = load_any_sch(name, os.path.splitext(os.path.basename(name))[0])
|
||||||
files = sch.get_files()
|
files = sch.get_files()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue