Loading and saving of status and importance now works

This commit is contained in:
Veronica K. B. Olsen
2019-05-19 22:49:24 +02:00
parent fdd9c58235
commit 823426f4f8
3 changed files with 79 additions and 11 deletions
+46
View File
@@ -13,6 +13,8 @@
import logging
import nw
from lxml import etree
from nw.enum import nwItemClass
from nw.common import checkInt
@@ -84,6 +86,50 @@ class NWStatus():
self.theCounts[theIndex] += 1
return
def packEntries(self, xParent):
for n in range(self.theLength):
xSub = etree.SubElement(xParent,"entry",attrib={
"red" : str(self.theColours[n][0]),
"green" : str(self.theColours[n][1]),
"blue" : str(self.theColours[n][2]),
})
xSub.text = self.theLabels[n]
return True
def unpackEntries(self, xParent):
theLabels = []
theColours = []
for xChild in xParent:
theLabels.append(xChild.text)
if "red" in xChild.attrib:
cR = checkInt(xChild.attrib["red"],0,False)
else:
cR = 0
if "green" in xChild.attrib:
cG = checkInt(xChild.attrib["green"],0,False)
else:
cG = 0
if "blue" in xChild.attrib:
cB = checkInt(xChild.attrib["blue"],0,False)
else:
cB = 0
theColours.append((cR,cG,cB))
if len(theLabels) > 0:
self.theLabels = []
self.theColours = []
self.theCounts = []
self.theMap = {}
self.theLength = 0
self.theIndex = 0
for n in range(len(theLabels)):
self.addEntry(theLabels[n], theColours[n])
return True
##
# Iterator Bits
##