aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad/read_schematic.py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-10-22 09:43:54 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-10-22 09:43:54 +0200
commit826a0eb82cc786d480888f3a032df95447c133b8 (patch)
treee8db0701756bf23283316ef04f13f364e37af6c2 /src/ee/kicad/read_schematic.py
parent0073712b71ea642edc2b67ad64a09cc0f54a137f (diff)
downloadee-python-826a0eb82cc786d480888f3a032df95447c133b8.tar.gz
ee-python-826a0eb82cc786d480888f3a032df95447c133b8.tar.bz2
ee-python-826a0eb82cc786d480888f3a032df95447c133b8.tar.xz
ee-python-826a0eb82cc786d480888f3a032df95447c133b8.zip
digikey.to_pandas(): Make sure that 'Digi-Key', 'MPN' and 'URL' fields
always are in the data frame. kicad.to_pandas(): support Schematics objects too. read_schematics(): Support hierarchical labels.
Diffstat (limited to 'src/ee/kicad/read_schematic.py')
-rw-r--r--src/ee/kicad/read_schematic.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/ee/kicad/read_schematic.py b/src/ee/kicad/read_schematic.py
index ed5ce21..914a86e 100644
--- a/src/ee/kicad/read_schematic.py
+++ b/src/ee/kicad/read_schematic.py
@@ -93,8 +93,9 @@ def read_schematic(path):
schematic.add_component(Component(position, timestamp, library, name, unit, ref, fields))
- def load(f):
+ def load(path, f):
header = f.readline()
+ line_number = 1
if "EESchema Schematic File Version" not in header:
raise EeException("Not a KiCAD schematic file.")
@@ -104,6 +105,7 @@ def read_schematic(path):
seen_end = False
while not seen_end:
line = f.readline()
+ line_number = line_number + 1
if not line:
break
@@ -135,27 +137,24 @@ def read_schematic(path):
section_name = parts[0]
# print("SECTION: {}".format(section_name))
section = []
- elif line == "Entry Wire Line":
- f.readline() # ignore the next line for now
- elif line.startswith("Text Label "):
- f.readline() # ignore the next line for now
- elif line.startswith("Text Notes "):
+ elif parts[0:3] == ["Entry", "Wire", "Line"] or \
+ parts[0:2] == ["Text", "Label"] or \
+ parts[0:2] == ["Text", "Notes"] or \
+ parts[0:2] == ["Text", "HLabel"] or \
+ parts[0:3] == ["Wire", "Notes", "Line"] or \
+ parts[0:3] == ["Wire", "Wire", "Line"] or \
+ parts[0:3] == ["Wire", "Bus", "Line"]:
f.readline() # ignore the next line for now
+ line_number = line_number + 1
elif line.startswith("NoConn "):
pass
- elif parts[0:3] == ["Wire", "Notes", "Line"]:
- f.readline() # ignore the next line for now
- elif parts[0:3] == ["Wire", "Wire", "Line"]:
- f.readline() # ignore the next line for now
- elif parts[0:3] == ["Wire", "Bus", "Line"]:
- f.readline() # ignore the next line for now
elif parts[0:2] == ["Connection", "~"]:
pass
else:
# print("line={}, len={}, wat={}".format(line, len(line), parts[0:3]))
- raise EeException("Bad line: {}".format(line))
+ raise EeException("{}:{}: Bad line: {}".format(path, line_number, line))
return schematic
with open(path) as file:
- return load(file)
+ return load(path, file)