All of lore.kernel.org
 help / color / mirror / Atom feed
* [2.0][PATCH 1/4] utils: Allow to_boolean to support int values
@ 2023-03-10 20:45 Martin Jansa
  2023-03-10 20:45 ` [2.0][PATCH 2/4] cookerdata: Remove incorrect SystemExit usage Martin Jansa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin Jansa @ 2023-03-10 20:45 UTC (permalink / raw)
  To: bitbake-devel; +Cc: steve, Richard Purdie

From: Richard Purdie <richard.purdie@linuxfoundation.org>

Some variables may be set as:

X = 1

as well the more usual

X = "1"

so add support to to_boolean to handle this case.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/utils.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index bca4830f2..cdb3c6864 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -990,6 +990,9 @@ def to_boolean(string, default=None):
     if not string:
         return default
 
+    if isinstance(string, int):
+        return string != 0
+
     normalized = string.lower()
     if normalized in ("y", "yes", "1", "true"):
         return True
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-10 20:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 20:45 [2.0][PATCH 1/4] utils: Allow to_boolean to support int values Martin Jansa
2023-03-10 20:45 ` [2.0][PATCH 2/4] cookerdata: Remove incorrect SystemExit usage Martin Jansa
2023-03-10 20:46 ` [2.0][PATCH 3/4] cookerdata: Improve early exception handling Martin Jansa
2023-03-10 20:46 ` [2.0][PATCH 4/4] cookerdata: Drop dubious exception handling code Martin Jansa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.