Project

General

Profile

« Previous | Next » 

Revision 3801

xml_func.py: _if(): Made cond optional. When it's not specified or None, it is treated as False. This supports cases where all elements of the condition are required but not mapped to.

View differences:

lib/xml_func.py
177 177

  
178 178
def _if(items, node):
179 179
    items = dict(items)
180
    try:
181
        cond = items['cond']
182
        then = items['then']
180
    try: then = items['then']
183 181
    except KeyError, e: raise SyntaxError(e)
182
    cond = items.get('cond', None)
184 183
    else_ = items.get('else', None)
185
    cond = bool(cast(strings.ustr, cond))
184
    
185
    cond = cond != None and bool(cast(strings.ustr, cond)) # None == False
186 186
    if cond: return then
187 187
    else: return else_
188 188
funcs['_if'] = _if

Also available in: Unified diff