templater: mark .gen as a private attribute
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 Mar 2018 20:56:42 +0900
changeset 37275 8c84dc8264dc
parent 37274 45987e2b64f0
child 37276 b4630e332a99
templater: mark .gen as a private attribute
mercurial/templateutil.py
--- a/mercurial/templateutil.py	Sun Mar 18 00:11:36 2018 +0900
+++ b/mercurial/templateutil.py	Sat Mar 17 20:56:42 2018 +0900
@@ -61,12 +61,13 @@
 
     def __init__(self, gen, values, makemap, joinfmt, keytype=None):
         if gen is not None:
-            self.gen = gen  # generator or function returning generator
+            self._gen = gen  # generator or function returning generator
         self._values = values
         self._makemap = makemap
         self.joinfmt = joinfmt
         self.keytype = keytype  # hint for 'x in y' where type(x) is unresolved
-    def gen(self):
+
+    def _gen(self):
         """Default generator to stringify this as {join(self, ' ')}"""
         for i, x in enumerate(self._values):
             if i > 0:
@@ -79,7 +80,7 @@
 
     def show(self, context, mapping):
         # TODO: switch gen to (context, mapping) API?
-        gen = self.gen
+        gen = self._gen
         if callable(gen):
             return gen()
         return gen
@@ -113,12 +114,12 @@
 
     def __init__(self, gen, key, value, makemap):
         if gen is not None:
-            self.gen = gen  # generator or function returning generator
+            self._gen = gen  # generator or function returning generator
         self._key = key
         self._value = value  # may be generator of strings
         self._makemap = makemap
 
-    def gen(self):
+    def _gen(self):
         yield pycompat.bytestr(self._value)
 
     def tomap(self):
@@ -129,7 +130,7 @@
 
     def show(self, context, mapping):
         # TODO: switch gen to (context, mapping) API?
-        gen = self.gen
+        gen = self._gen
         if callable(gen):
             return gen()
         return gen