diff options
Diffstat (limited to 'src/kicadtoNgspice/Model.py')
-rw-r--r-- | src/kicadtoNgspice/Model.py | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 3cc3a0cb..6de6d8df 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -1,6 +1,6 @@ from PyQt4 import QtGui -import json from . import TrackWidget +from xml.etree import ElementTree as ET import os @@ -18,18 +18,23 @@ class Model(QtGui.QWidget): kicadFile = clarg1 (projpath, filename) = os.path.split(kicadFile) project_name = os.path.basename(projpath) - + check = 1 try: f = open( os.path.join( projpath, project_name + - "_Previous_Values.json"), + "_Previous_Values.xml"), 'r') - data = f.read() - json_data = json.loads(data) + tree = ET.parse(f) + parent_root = tree.getroot() + for child in parent_root: + if child.tag == "model": + root = child + except BaseException: - print("Model Previous Values JSON is Empty") + check = 0 + print("Model Previous Values XML is Empty") # Creating track widget object self.obj_trac = TrackWidget.TrackWidget() @@ -73,17 +78,12 @@ class Model(QtGui.QWidget): [self.nextcount], self.nextrow, 1) try: - for mod in json_data["model"]: - if json_data["model"][mod]["type"] ==\ - line[2] and mod == line[3]: - ( - self.obj_trac.model_entry_var - [self.nextcount].setText( - str(list( - json_data - ["model"][mod]["values"] - [i].values())[0])) - ) + for child in root: + if child.text == line[2] \ + and child.tag == line[3]: + self.obj_trac.model_entry_var + [self.nextcount].setText( + str(child[i].text)) i = i + 1 except BaseException: pass @@ -105,20 +105,13 @@ class Model(QtGui.QWidget): ) try: - for mod in json_data["model"]: - if json_data["model"][mod]["type"] ==\ - line[2] and mod == line[3]: - ( - self.obj_trac.model_entry_var - [self.nextcount].setText( - str(list(json_data - ["model"][mod]["values"] - [i].values())[0])) - ) + for child in root: + if child.text == line[2] and child.tag == line[3]: + self.obj_trac.model_entry_var[self.nextcount] \ + .setText(str(child[i].text)) i = i + 1 except BaseException: pass - tag_dict[key] = self.nextcount self.nextcount = self.nextcount + 1 self.nextrow = self.nextrow + 1 |