comparison mercurial/templateutil.py @ 37163:0023da2910c9

templater: extract type conversion from evalfuncarg() Needed by the subsequent patches.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 23 Mar 2018 21:03:21 +0900
parents 53e6b7e05553
children 9ab3491f84c2
comparison
equal deleted inserted replaced
37162:53e6b7e05553 37163:0023da2910c9
285 func, data = arg 285 func, data = arg
286 return func(context, mapping, data) 286 return func(context, mapping, data)
287 287
288 def evalfuncarg(context, mapping, arg): 288 def evalfuncarg(context, mapping, arg):
289 """Evaluate given argument as value type""" 289 """Evaluate given argument as value type"""
290 thing = evalrawexp(context, mapping, arg) 290 return _unwrapvalue(evalrawexp(context, mapping, arg))
291
292 # TODO: unify this with unwrapvalue() once the bug of templatefunc.join()
293 # is fixed. we can't do that right now because join() has to take a generator
294 # of byte strings as it is, not a lazy byte string.
295 def _unwrapvalue(thing):
291 thing = unwrapvalue(thing) 296 thing = unwrapvalue(thing)
292 # evalrawexp() may return string, generator of strings or arbitrary object 297 # evalrawexp() may return string, generator of strings or arbitrary object
293 # such as date tuple, but filter does not want generator. 298 # such as date tuple, but filter does not want generator.
294 if isinstance(thing, types.GeneratorType): 299 if isinstance(thing, types.GeneratorType):
295 thing = stringify(thing) 300 thing = stringify(thing)