aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2011-01-21 00:57:14 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2011-01-21 00:57:14 -0500
commita223608dda0751551c6e8688c0c0e1c9a1d4e69c (patch)
treecd0620097745b7053abec7346f6bd7e65d99dafe /util
parentf45b5e262c394cf00ef88f7fca1eab1b4de0fec9 (diff)
Added a new config file to run the upstairs lights. Modified PixelMapper to
track cache hits. Added 60-strip layouts and renderer configs.
Diffstat (limited to 'util')
-rw-r--r--util/Config.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/util/Config.py b/util/Config.py
index 1e20cde..c2d8806 100644
--- a/util/Config.py
+++ b/util/Config.py
@@ -99,12 +99,19 @@ def fileToDict(fileName):
def pullArgsFromItem(parentNode):
attribArgs = {}
for arg in parentNode.attrib: #automatically pull attributes into the argdict
- attribArgs[arg] = parentNode.attrib[arg]
+ attribArgs[arg] = attemptEval(parentNode.attrib[arg])
argNode = parentNode.find('Args')
args = generateArgDict(argNode)
for key in attribArgs:
args[key] = attribArgs[key]
return args
+
+def attemptEval(val):
+ try:
+ val = eval(val)
+ except (NameError, SyntaxError):
+ val = str(val)
+ return val
def generateArgDict(parentNode, recurse=False):
args = {}
for arg in parentNode.getchildren():
@@ -113,10 +120,7 @@ def generateArgDict(parentNode, recurse=False):
value = generateArgDict(arg, True)
else:
#convert into python if possible, otherwise don't
- try:
- value = eval(arg.text)
- except (NameError,SyntaxError):
- value = str(arg.text)
+ value = attemptEval(arg.text)
if key in args: #build of lists of like-elements
if type(args[key]) != type([]):
args[key] = [args[key]]