Show More
@@ -113,15 +113,11 b' class mappable(wrapped):' | |||||
113 | """ |
|
113 | """ | |
114 |
|
114 | |||
115 | def __init__(self, gen, key, value, makemap): |
|
115 | def __init__(self, gen, key, value, makemap): | |
116 | if gen is not None: |
|
|||
117 |
|
|
116 | self._gen = gen # generator or function returning generator | |
118 | self._key = key |
|
117 | self._key = key | |
119 | self._value = value # may be generator of strings |
|
118 | self._value = value # may be generator of strings | |
120 | self._makemap = makemap |
|
119 | self._makemap = makemap | |
121 |
|
120 | |||
122 | def _gen(self): |
|
|||
123 | yield pycompat.bytestr(self._value) |
|
|||
124 |
|
||||
125 | def tomap(self): |
|
121 | def tomap(self): | |
126 | return self._makemap(self._key) |
|
122 | return self._makemap(self._key) | |
127 |
|
123 | |||
@@ -131,6 +127,8 b' class mappable(wrapped):' | |||||
131 | def show(self, context, mapping): |
|
127 | def show(self, context, mapping): | |
132 | # TODO: switch gen to (context, mapping) API? |
|
128 | # TODO: switch gen to (context, mapping) API? | |
133 | gen = self._gen |
|
129 | gen = self._gen | |
|
130 | if gen is None: | |||
|
131 | return pycompat.bytestr(self._value) | |||
134 | if callable(gen): |
|
132 | if callable(gen): | |
135 | return gen() |
|
133 | return gen() | |
136 | return gen |
|
134 | return gen |
General Comments 0
You need to be logged in to leave comments.
Login now