aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ee/kicad/read_schematic.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ee/kicad/read_schematic.py b/src/ee/kicad/read_schematic.py
index 55ed148..e70d1a7 100644
--- a/src/ee/kicad/read_schematic.py
+++ b/src/ee/kicad/read_schematic.py
@@ -18,12 +18,13 @@ def read_schematic(path):
library = None
name = None
unit = None
+ ref = None
fields = []
extra_lines = 0
for line in lines:
if line.startswith((' ', '\t')):
- parts = line.strip().split(" ")
+ # parts = line.strip().split(" ")
if extra_lines == 0:
pass
else:
@@ -45,13 +46,13 @@ def read_schematic(path):
elif parts[0] == "P" and len(parts) == 3:
position = Position(int(parts[1]), int(parts[2]))
elif parts[0] == "F" and len(parts) >= 10:
- oritentation = parts[3]
+ # orientation = parts[3]
pos = Position(int(parts[4]), int(parts[5]))
value = parts[2]
- size = parts[6]
- attributes = parts[7]
- justify = parts[8] # One of L, R, C
- textAttrs = parts[9] # tree characters,
+ # size = parts[6]
+ # attributes = parts[7]
+ # justify = parts[8] # One of L, R, C
+ # text_attrs = parts[9] # tree characters,
# 0: T=top justify, B=bottom justify, C=center
# 1: I=italics, N=normal
# 2: B=bold, N=normal
@@ -66,11 +67,12 @@ def read_schematic(path):
sheet.add_component(Component(position, timestamp, library, name, unit, ref, fields))
- with open(path) as f:
+ def load(f):
header = f.readline()
- if not "EESchema Schematic File Version" in header:
+ if "EESchema Schematic File Version" not in header:
raise EeException("Not a KiCAD schematic file.")
+ nonlocal sheet
sheet = schematic.first_sheet
section_name = None
@@ -129,3 +131,6 @@ def read_schematic(path):
raise EeException("Bad line: {}".format(line))
return schematic
+
+ with open(path) as file:
+ return load(file)