Show More
@@ -61,12 +61,13 b' class hybrid(wrapped):' | |||
|
61 | 61 | |
|
62 | 62 | def __init__(self, gen, values, makemap, joinfmt, keytype=None): |
|
63 | 63 | if gen is not None: |
|
64 | self.gen = gen # generator or function returning generator | |
|
64 | self._gen = gen # generator or function returning generator | |
|
65 | 65 | self._values = values |
|
66 | 66 | self._makemap = makemap |
|
67 | 67 | self.joinfmt = joinfmt |
|
68 | 68 | self.keytype = keytype # hint for 'x in y' where type(x) is unresolved |
|
69 | def gen(self): | |
|
69 | ||
|
70 | def _gen(self): | |
|
70 | 71 | """Default generator to stringify this as {join(self, ' ')}""" |
|
71 | 72 | for i, x in enumerate(self._values): |
|
72 | 73 | if i > 0: |
@@ -79,7 +80,7 b' class hybrid(wrapped):' | |||
|
79 | 80 | |
|
80 | 81 | def show(self, context, mapping): |
|
81 | 82 | # TODO: switch gen to (context, mapping) API? |
|
82 | gen = self.gen | |
|
83 | gen = self._gen | |
|
83 | 84 | if callable(gen): |
|
84 | 85 | return gen() |
|
85 | 86 | return gen |
@@ -113,12 +114,12 b' class mappable(wrapped):' | |||
|
113 | 114 | |
|
114 | 115 | def __init__(self, gen, key, value, makemap): |
|
115 | 116 | if gen is not None: |
|
116 | self.gen = gen # generator or function returning generator | |
|
117 | self._gen = gen # generator or function returning generator | |
|
117 | 118 | self._key = key |
|
118 | 119 | self._value = value # may be generator of strings |
|
119 | 120 | self._makemap = makemap |
|
120 | 121 | |
|
121 | def gen(self): | |
|
122 | def _gen(self): | |
|
122 | 123 | yield pycompat.bytestr(self._value) |
|
123 | 124 | |
|
124 | 125 | def tomap(self): |
@@ -129,7 +130,7 b' class mappable(wrapped):' | |||
|
129 | 130 | |
|
130 | 131 | def show(self, context, mapping): |
|
131 | 132 | # TODO: switch gen to (context, mapping) API? |
|
132 | gen = self.gen | |
|
133 | gen = self._gen | |
|
133 | 134 | if callable(gen): |
|
134 | 135 | return gen() |
|
135 | 136 | return gen |
General Comments 0
You need to be logged in to leave comments.
Login now