Mercurial > hg-stable
changeset 37323:8c31b434697f
templater: define interface for objects which act as iterator of mappings
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 Mar 2018 21:21:50 +0900 |
parents | a67fd1fe5109 |
children | c2f74b8f6b7f |
files | mercurial/templateutil.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templateutil.py Wed Apr 04 23:26:49 2018 +0900 +++ b/mercurial/templateutil.py Sat Mar 17 21:21:50 2018 +0900 @@ -38,6 +38,10 @@ __metaclass__ = abc.ABCMeta @abc.abstractmethod + def itermaps(self): + """Yield each template mapping""" + + @abc.abstractmethod def show(self, context, mapping): """Return a bytes or (possibly nested) generator of bytes representing the underlying object @@ -493,7 +497,7 @@ def runmap(context, mapping, data): darg, targ = data d = evalrawexp(context, mapping, darg) - if util.safehasattr(d, 'itermaps'): + if isinstance(d, wrapped): diter = d.itermaps() else: try: