diff options
Diffstat (limited to 'mercurial/templater.py')
-rw-r--r-- | mercurial/templater.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/mercurial/templater.py b/mercurial/templater.py index 16558da..2d8dbdd 100644 --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -135,7 +135,7 @@ def runsymbol(context, mapping, key): v = mapping.get(key) if v is None: v = context._defaults.get(key, '') - if util.safehasattr(v, '__call__'): + if hasattr(v, '__call__'): return v(**mapping) return v @@ -172,14 +172,14 @@ def runmap(context, mapping, data): def buildfunc(exp, context): n = getsymbol(exp[1]) args = [compileexp(x, context) for x in getlist(exp[2])] - if n in funcs: - f = funcs[n] - return (f, args) if n in context._filters: if len(args) != 1: raise error.ParseError(_("filter %s expects one argument") % n) f = context._filters[n] return (runfilter, (args[0][0], args[0][1], f)) + elif n in context._funcs: + f = context._funcs[n] + return (f, args) methods = { "string": lambda e, c: (runstring, e[1]), @@ -191,9 +191,6 @@ methods = { "func": buildfunc, } -funcs = { -} - # template engine path = ['templates', '../templates'] @@ -203,14 +200,14 @@ def _flatten(thing): '''yield a single stream from a possibly nested set of iterators''' if isinstance(thing, str): yield thing - elif not util.safehasattr(thing, '__iter__'): + elif not hasattr(thing, '__iter__'): if thing is not None: yield str(thing) else: for i in thing: if isinstance(i, str): yield i - elif not util.safehasattr(i, '__iter__'): + elif not hasattr(i, '__iter__'): if i is not None: yield str(i) elif i is not None: @@ -312,7 +309,7 @@ class templater(object): def load(self, t): '''Get the template for the given template name. Use a local cache.''' - if t not in self.cache: + if not t in self.cache: try: self.cache[t] = util.readfile(self.map[t][1]) except KeyError, inst: @@ -341,7 +338,7 @@ def templatepath(name=None): normpaths = [] # executable version (py2exe) doesn't support __file__ - if util.mainfrozen(): + if hasattr(sys, 'frozen'): module = sys.executable else: module = __file__ |