Skip to content

Commit

Permalink
[KiRi][Changed] Don't stop on corrupted schematics
Browse files Browse the repository at this point in the history
See #583
  • Loading branch information
set-soft committed Feb 15, 2024
1 parent 1d8ec52 commit 9b345f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.6.5] - Unreleased
### Changed
- KiRi: continue even on corrupted schematics (#583)

### Fixed
- Netlist generation problems with components on the PCB but not in schematic.
(#578)
Expand Down
14 changes: 9 additions & 5 deletions kibot/kiplot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2023 Salvador E. Tropea
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2024 Salvador E. Tropea
# Copyright (c) 2020-2024 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2018 John Beard
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
Expand Down Expand Up @@ -238,7 +238,7 @@ def ki_conf_error(e):
'Line content: `{}`'.format(e.code.rstrip())), EXIT_BAD_CONFIG)


def load_any_sch(file, project):
def load_any_sch(file, project, fatal=True, extra_msg=None):
if file[-9:] == 'kicad_sch':
sch = SchematicV6()
load_libs = False
Expand All @@ -252,10 +252,14 @@ def load_any_sch(file, project):
if GS.debug_level > 1:
logger.debug('Schematic dependencies: '+str(sch.get_files()))
except SchFileError as e:
if extra_msg is not None:
logger.error(extra_msg)
GS.exit_with_error(('At line {} of `{}`: {}'.format(e.line, e.file, e.msg),
'Line content: `{}`'.format(e.code)), CORRUPTED_SCH)
'Line content: `{}`'.format(e.code)), CORRUPTED_SCH if fatal else DONT_STOP)
except SchError as e:
GS.exit_with_error(('While loading `{}`'.format(file), str(e)), CORRUPTED_SCH)
if extra_msg is not None:
logger.error(extra_msg)
GS.exit_with_error(('While loading `{}`'.format(file), str(e)), CORRUPTED_SCH if fatal else DONT_STOP)
except KiConfError as e:
ki_conf_error(e)
return sch
Expand Down
2 changes: 1 addition & 1 deletion kibot/out_kiri.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def solve_layer_colors(self):

def save_sch_sheet(self, hash, name_sch):
# Load the schematic. Really worth?
sch = load_any_sch(name_sch, GS.sch_basename)
sch = load_any_sch(name_sch, GS.sch_basename, fatal=False, extra_msg=f'Commit: {hash}')
with open(os.path.join(self.cache_dir, hash[:7], '_KIRI_', 'sch_sheets'), 'wt') as f:
base_dir = os.path.dirname(name_sch)
for s in sorted(sch.all_sheets, key=lambda x: x.sheet_path_h):
Expand Down

0 comments on commit 9b345f8

Please sign in to comment.