]> code.ossystems Code Review - openembedded-core.git/commitdiff
oe/types: Allow boolean to accept an existing boolean
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 20 Jun 2018 23:14:31 +0000 (00:14 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 20 Jun 2018 23:16:49 +0000 (00:16 +0100)
Exception: TypeError: boolean accepts a string, not '<class 'bool'>

is a bit annoying if you pass in True/False. Tweak the function
to make it forgive that situation.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/types.py

index 4ae58acfacc77c02e0f83fc0cea36c63c3efdf6e..f778c1de689abef83c8e0afce96495483f4565af 100644 (file)
@@ -105,6 +105,8 @@ def boolean(value):
     Valid values for true: 'yes', 'y', 'true', 't', '1'
     Valid values for false: 'no', 'n', 'false', 'f', '0'
     """
+    if isinstance(value, bool):
+        return value
 
     if not isinstance(value, str):
         raise TypeError("boolean accepts a string, not '%s'" % type(value))