summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-14 21:41:17 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-14 21:41:23 +0100
commitb7331d8984629b8115199b2e0f1de331219df9cc (patch)
tree2f101566d587c92eeddd68d065a5d355f22dc581
parentinfo: drm requires membership of video (diff)
downloadblueshift-b7331d8984629b8115199b2e0f1de331219df9cc.tar.gz
blueshift-b7331d8984629b8115199b2e0f1de331219df9cc.tar.bz2
blueshift-b7331d8984629b8115199b2e0f1de331219df9cc.tar.xz
fix tree eval errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--examples/lisp-esque28
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/lisp-esque b/examples/lisp-esque
index 36b02d2..8b42d6e 100644
--- a/examples/lisp-esque
+++ b/examples/lisp-esque
@@ -145,7 +145,7 @@ def _monitors(mods, args):
@param mods:[] Not used
@param args:list<str> Indices of outputs, <screen>: or <screen>:<output> or 'nil', empty for all
'''
- pass
+ print('Selected monitors: %s' % ','.join(evaluate_tree(args, True)))
def _crtc(mods, args):
@@ -590,27 +590,33 @@ def evaluate_tree(elements, implied_functions = True):
if elements[0] == '.':
elements = elements[1:]
else:
- cand = elements[0].split(':')[0]
- if cand in functions.keys():
- elements = ['0' + elements[0], elements[1:]]
- for i in range(len(elements)):
+ if isinstance(elements[0], str):
+ cand = elements[0].split(':')[0]
+ if cand in functions.keys():
+ elements = [':' + elements[0], elements[1:]]
+ i, n = 0, len(elements)
+ while i < n:
element = elements[i]
- if element.startswith(':'):
+ if isinstance(element, str) and element.startswith(':'):
if i + 1 < len(elements):
args = elements[i + 1]
i += 1
if isinstance(args, str):
args = [args]
- element = element[0].split(':')
- rc += functions[element[0]](element[1:], args)
+ element = element[1:].split(':')
+ ret = functions[element[0]](element[1:], args)
+ if ret is not None:
+ rc += ret
else:
- if not isinstance(args, str):
+ if not isinstance(element, str):
element = evaluate_tree(element, implied_functions)
- rc.append(element)
+ if element is not None:
+ rc.append(element)
+ i += 1
return rc
# Evaluate tree
-parse_tree(conf, True)
+evaluate_tree(conf, True)
conf = None