From 82532ffab049633d049752c4fca4687f4a51482d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 30 Jan 2024 08:19:04 -0300 Subject: [PATCH] [Schematic v6][Fixed] Targets - We always collected the v5 targets - Detect flat hierarchy --- CHANGELOG.md | 1 + kibot/kicad/v6_sch.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10900bf6..c521b4ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Schematics: - Problems with deep nested and recycled sheets (#520) - Problems saving deep nested sheets + - Makefile/compress targets - Rotated polygons and text used in the worksheet (#466) - The --log/-L didn't enabled full debug for all messages - BoM: diff --git a/kibot/kicad/v6_sch.py b/kibot/kicad/v6_sch.py index 16b4c002..88d50531 100644 --- a/kibot/kicad/v6_sch.py +++ b/kibot/kicad/v6_sch.py @@ -1916,7 +1916,7 @@ class SchematicV6(Schematic): f.write(dumps(lib)) f.write('\n') - def save(self, fname=None, dest_dir=None, base_sheet=None, saved=None, cross=False, exp_hierarchy=False): + def save(self, fname=None, dest_dir=None, base_sheet=None, saved=None, cross=False, exp_hierarchy=False, dry=False): # Switch to the current version global version version = self.version @@ -1946,7 +1946,7 @@ class SchematicV6(Schematic): # Save all in dest_dir (variant) fname = os.path.join(dest_dir, fname) # Save the sheet - if fname not in saved: + if fname not in saved and not dry: sch = [Symbol('kicad_sch')] sch.append(_symbol('version', [self.version])) sch.append(_symbol('generator', [Symbol(self.generator)])) @@ -2028,17 +2028,25 @@ class SchematicV6(Schematic): with GS.create_file(fname) as f: f.write(dumps(sch)) f.write('\n') + if fname not in saved: saved.add(fname) for sch in self.sheets: if sch.sch: sch.sch.save(sch.flat_file if exp_hierarchy else sch.sch.fname_rel, dest_dir, base_sheet, saved, cross=cross, - exp_hierarchy=exp_hierarchy) + exp_hierarchy=exp_hierarchy, dry=dry) def save_variant(self, dest_dir): fname = os.path.basename(self.fname) self.save(fname, dest_dir, cross=True, exp_hierarchy=self.check_exp_hierarchy()) return fname + def file_names_variant(self, dest_dir): + """ Returns a list of file names created by save_variant() """ + saved = set() + fname = os.path.basename(self.fname) + self.save(fname, dest_dir, cross=True, exp_hierarchy=self.check_exp_hierarchy(), dry=True, saved=saved) + return saved + def check_exp_hierarchy(self): """ Check if we really need to expand the hierarchy """ # KiCad v6: we can change the value and footprint, but won't work when imported by v7