Skip to contentSkip to conversation

contrib: allow override-style syntax for vars & routines

PATCH New Jeremy Kerr 1 participant 2 messages Dec 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 contrib: allow override-style syntax for vars & routines

Currently, the variable and routine regexes don't support the override-style syntax. This means we may break routine blocks, as we don't recognise overridden routines with an :append/:prepend/etc.

This change adds the ":" char to the var & routine regexes.

---
 contrib/oe-stylize.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
contrib/oe-stylize.py +2 -2
index e1ba1b321..67c06b1bb 100755
@@ -210,8 +210,8 @@ OE_vars = [
     'others'
 ]
 
-varRegexp = r'^([a-zA-Z_0-9${}-]*)([ \t]*)([+.:]?=[+.]?)([ \t]*)([^\t]+)'
-routineRegexp = r'^([a-zA-Z0-9_ ${}-]+?)\('
+varRegexp = r'^([a-zA-Z_0-9${}:-]*)([ \t]*)([+.:]?=[+.]?)([ \t]*)([^\t]+)'
+routineRegexp = r'^([a-zA-Z0-9_ ${}:-]+?)\('
 
 # Variables seen in the processed .bb
 seen_vars = {}
Signature · 1 line
2.33.0
#1 lore raw

PATCH 2/2 contrib: fix python warnings for oe-stylize

I get a couple of python SyntaxWarnings when running oe-stylize:

[jk@pecola meta-openembedded]$ python3 contrib/oe-stylize.py contrib/oe-stylize.py:372: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if line is not '':
contrib/oe-stylize.py:389: SyntaxWarning: "is" with a literal. Did you mean "=="?
if line.isspace() or line is '':

The 'is' operator is for object reference comparison, which is not what we want here. Change to '==' / '!=' instead.

---
 contrib/oe-stylize.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
contrib/oe-stylize.py +2 -2
index 67c06b1bb..30b460e12 100755
@@ -369,7 +369,7 @@ if __name__ == "__main__":
             line = line.expandtabs().rstrip()
             # ignore empty lines (or line filled with spaces or tabs only)
             # so that rule6 is always respected
-            if line is not '':
+            if line != '':
                 lines.append(line)
 
     # -- parse the file --
@@ -386,7 +386,7 @@ if __name__ == "__main__":
         line = follow_rule(6, line)
 
         # ignore empty lines
-        if line.isspace() or line is '':
+        if line.isspace() or line == '':
             # flush comments into the olines
             for c in commentBloc:
                 olines.append(c)
Signature · 1 line
2.33.0