From a223608dda0751551c6e8688c0c0e1c9a1d4e69c Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Fri, 21 Jan 2011 00:57:14 -0500 Subject: Added a new config file to run the upstairs lights. Modified PixelMapper to track cache hits. Added 60-strip layouts and renderer configs. --- util/Config.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'util') 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]] -- cgit v1.2.3