Python conftree: valToBool method

This commit is contained in:
Jean-Francois Dockes 2021-12-18 19:06:00 +01:00
parent 3a5c1a0b6b
commit 0b6aa25dd4

View File

@ -304,3 +304,14 @@ def stringsToString(vs):
out.append(s)
return " ".join(out)
def valToBool(s):
if not s:
return False
try:
val = int(s)
return val != 0
except:
pass
if type(s) == type(b''):
s = s.decode("UTF-8")
return s[0] in "tTyY"