]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
ast: Fix support for anonymous methods in wildcard .bbappend files
authorJacob Kroon <jacob.kroon@mikrodidakt.se>
Sat, 22 Feb 2014 16:52:29 +0000 (17:52 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 24 Feb 2014 11:41:47 +0000 (11:41 +0000)
When using wildcard .bbappend files with anonymous methods in them,
bitbake/python fails to parse the generated code since the '%' is encoded
in the generated method name.

Fix this by including '%' in the convert-to-underscore list during
method name mangling.

While we're at it, move the method name mangling translation table
to a class variable, as suggested by Chris Larson.

[YOCTO #5864]

Signed-off-by: Jacob Kroon <jacob.kroon@mikrodidakt.se>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/parse/ast.py

index a2020532eae15555b47692740ce7531eeca042c1..d8c141b37ce1d689eedd322300ad18f29b366ccd 100644 (file)
@@ -139,6 +139,8 @@ class DataNode(AstNode):
             data.setVar(key, val, **loginfo)
 
 class MethodNode(AstNode):
+    tr_tbl = string.maketrans('/.+-@%', '______')
+
     def __init__(self, filename, lineno, func_name, body):
         AstNode.__init__(self, filename, lineno)
         self.func_name = func_name
@@ -147,7 +149,7 @@ class MethodNode(AstNode):
     def eval(self, data):
         text = '\n'.join(self.body)
         if self.func_name == "__anonymous":
-            funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-@', '_____'))))
+            funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(MethodNode.tr_tbl)))
             text = "def %s(d):\n" % (funcname) + text
             bb.methodpool.insert_method(funcname, text, self.filename)
             anonfuncs = data.getVar('__BBANONFUNCS') or []