summaryrefslogtreecommitdiff
path: root/src/kicadtoNgspice/Model.py
diff options
context:
space:
mode:
authorrahulp132020-02-23 17:06:49 +0530
committerrahulp132020-02-23 17:06:49 +0530
commitde3096c51107371de2361921dca8ee785e643fc3 (patch)
tree9383ca5dfa55da43e8a41d1a678b3127b476da59 /src/kicadtoNgspice/Model.py
parent567e3b725fcc9d22e27cfd854a573d3e64deaff1 (diff)
downloadeSim-de3096c51107371de2361921dca8ee785e643fc3.tar.gz
eSim-de3096c51107371de2361921dca8ee785e643fc3.tar.bz2
eSim-de3096c51107371de2361921dca8ee785e643fc3.zip
revert to xml from json
Diffstat (limited to 'src/kicadtoNgspice/Model.py')
-rw-r--r--src/kicadtoNgspice/Model.py49
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