Make match object function private to kwtemplater.substitute
authorChristian Ebert <blacktrash@gmx.net>
Mon, 26 Nov 2007 12:29:23 +0100
changeset 301 e92c6762e2be
parent 300 583efc0983f1
child 302 caa3d683cfcf
Make match object function private to kwtemplater.substitute
hgkw/keyword.py
--- a/hgkw/keyword.py	Mon Nov 26 12:24:16 2007 +0100
+++ b/hgkw/keyword.py	Mon Nov 26 12:29:23 2007 +0100
@@ -127,21 +127,22 @@
             self.t = cmdutil.changeset_templater(self.ui, self.repo,
                                                  False, '', False)
 
-    def kwsub(self, mobj):
-        '''Substitutes keyword using corresponding template.'''
-        kw = mobj.group(1)
-        self.t.use_template(self.templates[kw])
-        self.ui.pushbuffer()
-        self.t.show(changenode=self.node, root=self.repo.root, file=self.path)
-        keywordsub = templater.firstline(self.ui.popbuffer())
-        return '$%s: %s $' % (kw, keywordsub)
-
     def substitute(self, node, data, subfunc):
         '''Obtains node if missing, and calls given substitution function.'''
         if not self.node:
             c = context.filectx(self.repo, self.path, fileid=node)
             self.node = c.node()
-        return subfunc(self.kwsub, data)
+
+        def kwsub(mobj):
+            '''Substitutes keyword using corresponding template.'''
+            kw = mobj.group(1)
+            self.t.use_template(self.templates[kw])
+            self.ui.pushbuffer()
+            self.t.show(changenode=self.node,
+                        root=self.repo.root, file=self.path)
+            return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer()))
+
+        return subfunc(kwsub, data)
 
     def expand(self, node, data):
         '''Returns data with keywords expanded.'''