mercurial/templater.py
changeset 28331 2874db5462d3
parent 28225 5c11702fe2a3
child 28332 e91371633127
equal deleted inserted replaced
28330:f3fb24e36d61 28331:2874db5462d3
   435     attribute on these types."""
   435     attribute on these types."""
   436     if len(args) != 2:
   436     if len(args) != 2:
   437         # i18n: "get" is a keyword
   437         # i18n: "get" is a keyword
   438         raise error.ParseError(_("get() expects two arguments"))
   438         raise error.ParseError(_("get() expects two arguments"))
   439 
   439 
   440     dictarg = args[0][0](context, mapping, args[0][1])
   440     dictarg = evalfuncarg(context, mapping, args[0])
   441     if not util.safehasattr(dictarg, 'get'):
   441     if not util.safehasattr(dictarg, 'get'):
   442         # i18n: "get" is a keyword
   442         # i18n: "get" is a keyword
   443         raise error.ParseError(_("get() expects a dict as first argument"))
   443         raise error.ParseError(_("get() expects a dict as first argument"))
   444 
   444 
   445     key = args[1][0](context, mapping, args[1][1])
   445     key = evalfuncarg(context, mapping, args[1])
   446     return dictarg.get(key)
   446     return dictarg.get(key)
   447 
   447 
   448 def if_(context, mapping, args):
   448 def if_(context, mapping, args):
   449     """:if(expr, then[, else]): Conditionally execute based on the result of
   449     """:if(expr, then[, else]): Conditionally execute based on the result of
   450     an expression."""
   450     an expression."""