diff mbox series

[2/3] bb/data_smart: fix override syntax warning

Message ID GV1PR07MB91203D2CA5B12F4DD0287BB1A86D2@GV1PR07MB9120.eurprd07.prod.outlook.com
State New
Headers show
Series [1/3] bb/data_smart: remove dead code | expand

Commit Message

Konrad Weihmann Sept. 21, 2024, 12:09 p.m. UTC
when defining a function do_removesomething,
the parser warned about

Variable do_removesomething contains an operation using the
old override syntax. Please convert this layer/metadata before
attempting to use with a newer bitbake

correct it would be to search for a override operator at the end
of the string or for the next operator

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
---
 lib/bb/data_smart.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Richard Purdie Sept. 21, 2024, 4:09 p.m. UTC | #1
On Sat, 2024-09-21 at 12:09 +0000, Konrad Weihmann via lists.openembedded.org wrote:
> when defining a function do_removesomething,
> the parser warned about
> 
> Variable do_removesomething contains an operation using the
> old override syntax. Please convert this layer/metadata before
> attempting to use with a newer bitbake
> 
> correct it would be to search for a override operator at the end
> of the string or for the next operator
> 
> Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
> ---
>  lib/bb/data_smart.py | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
> index 4e15a43c2..49cd4357a 100644
> --- a/lib/bb/data_smart.py
> +++ b/lib/bb/data_smart.py
> @@ -539,8 +539,7 @@ class DataSmart(MutableMapping):
>          return var in self.overridedata
>  
>      def setVar(self, var, value, **loginfo):
> -
> -        if not var.startswith("__anon_") and ("_append" in var or "_prepend" in var or "_remove" in var):
> +        if not var.startswith("__anon_") and re.search(r"(_append|_prepend|_remove)(_|$)", var):
>              info = "%s" % var
>              if "file" in loginfo:
>                  info += " file: %s" % loginfo["file"]
> 

We can't add a non pre-compiled regex into a code hot path. Even a
precompiled regex is going to be relatively slow at that code point.
That is why it is using "in" and it was a relatively loose test.

Cheers,

Richard
diff mbox series

Patch

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 4e15a43c2..49cd4357a 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -539,8 +539,7 @@  class DataSmart(MutableMapping):
         return var in self.overridedata
 
     def setVar(self, var, value, **loginfo):
-
-        if not var.startswith("__anon_") and ("_append" in var or "_prepend" in var or "_remove" in var):
+        if not var.startswith("__anon_") and re.search(r"(_append|_prepend|_remove)(_|$)", var):
             info = "%s" % var
             if "file" in loginfo:
                 info += " file: %s" % loginfo["file"]