316 # other objects are evaluated as strings, which means 0 is True, but |
316 # other objects are evaluated as strings, which means 0 is True, but |
317 # empty dict/list should be False as they are expected to be '' |
317 # empty dict/list should be False as they are expected to be '' |
318 return bool(stringify(thing)) |
318 return bool(stringify(thing)) |
319 |
319 |
320 def evalinteger(context, mapping, arg, err=None): |
320 def evalinteger(context, mapping, arg, err=None): |
321 v = evalfuncarg(context, mapping, arg) |
321 return unwrapinteger(evalrawexp(context, mapping, arg), err) |
|
322 |
|
323 def unwrapinteger(thing, err=None): |
|
324 thing = _unwrapvalue(thing) |
322 try: |
325 try: |
323 return int(v) |
326 return int(thing) |
324 except (TypeError, ValueError): |
327 except (TypeError, ValueError): |
325 raise error.ParseError(err or _('not an integer')) |
328 raise error.ParseError(err or _('not an integer')) |
326 |
329 |
327 def evalstring(context, mapping, arg): |
330 def evalstring(context, mapping, arg): |
328 return stringify(evalrawexp(context, mapping, arg)) |
331 return stringify(evalrawexp(context, mapping, arg)) |