aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
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]]