Skip to content

Commit

Permalink
Better schematics filename handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MitjaNemec committed Apr 3, 2023
1 parent 423c9bb commit 6f5ab45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ place_footprints_test_projects/.directory
/place_footprints_test_projects/place_footprints_temp_sheet_linear.kicad_pcb
/place_footprints_test_projects/place_footprints_temp_sheet_matrix.kicad_pcb
/place_footprints_test_projects/*.log
error_dialog_GUI.py
15 changes: 11 additions & 4 deletions place_footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def __init__(self, board):
pass

def parse_schematic_files(self, filename, dict_of_sheets):
with open(filename) as f:
with open(filename, encoding='utf-8') as f:
contents = f.read().split("\n")
filename_dir = os.path.dirname(filename)
# find (sheet (at and then look in next few lines for new schematics file
for i in range(len(contents)):
line = contents[i]
Expand All @@ -206,11 +207,17 @@ def parse_schematic_files(self, filename, dict_of_sheets):
logger.info(f'Did not found sheetfile and/or sheetname properties in the schematic file '
f'in {filename} line:{str(i)}')
raise LookupError(f'Did not found sheetfile and/or sheetname properties in the schematic file '
f'in {filename} line:{str(i)}. Unsupported schematics file format')
f'in {filename} line:{str(i)}. Unsupported schematics file format')

sheetfilepath = os.path.join(filename_dir, sheetfile)
# here I should find all sheet data
dict_of_sheets[sheet_id] = [sheetname, sheetfile]
dict_of_sheets[sheet_id] = [sheetname, sheetfilepath]
# test if newfound file can be opened
if not os.path.exists(sheetfilepath):
raise LookupError(f'File {sheetfilepath} does not exists. This is either due to error in parsing'
f' schematics files, missing schematics file or an error within the schematics')
# open a newfound file and look for nested sheets
self.parse_schematic_files(sheetfile, dict_of_sheets)
self.parse_schematic_files(sheetfilepath, dict_of_sheets)
return

def get_list_of_footprints_with_same_id(self, fp_id):
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.11
1.2.12

0 comments on commit 6f5ab45

Please sign in to comment.