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 5c934a6 commit 8f0f551
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions save_restore_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def __init__(self, board, dont_parse_schematics=False):
def parse_schematic_files(self, filename, dict_of_sheets):
with open(filename) 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 @@ -203,10 +204,15 @@ def parse_schematic_files(self, filename, dict_of_sheets):
sheetname = contents[j].lstrip("(property \"Sheet name\"").split()[0].replace("\"", "")
if "(property \"Sheet file\"" in contents[j]:
sheetfile = contents[j].lstrip("(property \"Sheet file\"").split()[0].replace("\"", "")
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_fp_by_ref(self, ref):
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.10
1.1.11

0 comments on commit 8f0f551

Please sign in to comment.