Mercurial > public > mercurial-scm > hg
comparison mercurial/templateutil.py @ 37329:676664592313
templater: mark .joinfmt as a private attribute
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 Mar 2018 22:30:25 +0900 |
parents | ebf139cbd4a1 |
children | 0b64416224d9 |
comparison
equal
deleted
inserted
replaced
37328:11d51e518808 | 37329:676664592313 |
---|---|
85 | 85 |
86 def __init__(self, gen, values, makemap, joinfmt, keytype=None): | 86 def __init__(self, gen, values, makemap, joinfmt, keytype=None): |
87 self._gen = gen # generator or function returning generator | 87 self._gen = gen # generator or function returning generator |
88 self._values = values | 88 self._values = values |
89 self._makemap = makemap | 89 self._makemap = makemap |
90 self.joinfmt = joinfmt | 90 self._joinfmt = joinfmt |
91 self.keytype = keytype # hint for 'x in y' where type(x) is unresolved | 91 self.keytype = keytype # hint for 'x in y' where type(x) is unresolved |
92 | 92 |
93 def itermaps(self, context): | 93 def itermaps(self, context): |
94 makemap = self._makemap | 94 makemap = self._makemap |
95 for x in self._values: | 95 for x in self._values: |
96 yield makemap(x) | 96 yield makemap(x) |
97 | 97 |
98 def join(self, context, mapping, sep): | 98 def join(self, context, mapping, sep): |
99 # TODO: switch gen to (context, mapping) API? | 99 # TODO: switch gen to (context, mapping) API? |
100 return joinitems((self.joinfmt(x) for x in self._values), sep) | 100 return joinitems((self._joinfmt(x) for x in self._values), sep) |
101 | 101 |
102 def show(self, context, mapping): | 102 def show(self, context, mapping): |
103 # TODO: switch gen to (context, mapping) API? | 103 # TODO: switch gen to (context, mapping) API? |
104 gen = self._gen | 104 gen = self._gen |
105 if gen is None: | 105 if gen is None: |