comparison mercurial/templater.py @ 21798:f2c617ff2abc

templater: restore use of callable() since it was readded in Python 3.2
author Augie Fackler <raf@durin42.com>
date Mon, 23 Jun 2014 09:24:56 -0400
parents d8fb835376d1
children 4a445dc5abff
comparison
equal deleted inserted replaced
21797:b009dd135aa0 21798:f2c617ff2abc
146 if v is None: 146 if v is None:
147 try: 147 try:
148 v = context.process(key, mapping) 148 v = context.process(key, mapping)
149 except TemplateNotFound: 149 except TemplateNotFound:
150 v = '' 150 v = ''
151 if util.safehasattr(v, '__call__'): 151 if callable(v):
152 return v(**mapping) 152 return v(**mapping)
153 if isinstance(v, types.GeneratorType): 153 if isinstance(v, types.GeneratorType):
154 v = list(v) 154 v = list(v)
155 mapping[key] = v 155 mapping[key] = v
156 return v 156 return v
183 yield func(context, mapping, data) 183 yield func(context, mapping, data)
184 184
185 def runmap(context, mapping, data): 185 def runmap(context, mapping, data):
186 func, data, ctmpl = data 186 func, data, ctmpl = data
187 d = func(context, mapping, data) 187 d = func(context, mapping, data)
188 if util.safehasattr(d, '__call__'): 188 if callable(d):
189 d = d() 189 d = d()
190 190
191 lm = mapping.copy() 191 lm = mapping.copy()
192 192
193 for i in d: 193 for i in d:
333 if not (1 <= len(args) <= 2): 333 if not (1 <= len(args) <= 2):
334 # i18n: "join" is a keyword 334 # i18n: "join" is a keyword
335 raise error.ParseError(_("join expects one or two arguments")) 335 raise error.ParseError(_("join expects one or two arguments"))
336 336
337 joinset = args[0][0](context, mapping, args[0][1]) 337 joinset = args[0][0](context, mapping, args[0][1])
338 if util.safehasattr(joinset, '__call__'): 338 if callable(joinset):
339 jf = joinset.joinfmt 339 jf = joinset.joinfmt
340 joinset = [jf(x) for x in joinset()] 340 joinset = [jf(x) for x in joinset()]
341 341
342 joiner = " " 342 joiner = " "
343 if len(args) > 1: 343 if len(args) > 1: