Since the current extract function only allowed arguments to go on a single
line I wrote this to allow multiline arguments.
def extract_multiline_nodelist_options(nodelist, context=None):
"""
Returns a dict containing the key=value options listed within the nodelist.
The value can be a python dict, list, tuple, or number/string literal.
"""
ret={}
if context:
rendered = nodelist.render(context)
else:
rendered = nodelist.render({})
if rendered.find("=") > 0:
opts = rendered.split("\n")
for i in range(len(opts)):
while i+1 < len(opts) and opts[i+1].find("=") == -1:
opts[i] += opts.pop(i+1)
for key, val in [opt.strip().split("=") for opt in opts if opt != ""]:
ret[key.strip()]=eval(val.strip())
return ret
Original issue reported on code.google.com by mtthw.me...@gmail.com on 4 Aug 2009 at 2:41
Original issue reported on code.google.com by
mtthw.me...@gmail.com
on 4 Aug 2009 at 2:41