Utilities/__init__.py

changeset 2030
db11a2fe9bbc
parent 1914
fa4d57a6c3a9
child 2079
febae63bb821
--- a/Utilities/__init__.py	Sat Sep 08 18:20:46 2012 +0200
+++ b/Utilities/__init__.py	Sun Sep 09 14:46:59 2012 +0200
@@ -1678,6 +1678,21 @@
     
     return True
 
+
+def toBool(dataStr):
+    """
+    Module function to convert a string to a boolean value.
+    
+    @param dataStr string to be converted (string)
+    @return converted boolean value (boolean)
+    """
+    if dataStr in [ "True", "true", "1", "Yes", "yes"]:
+        return True
+    elif dataStr in ["False", "false", "0", "No", "no"]:
+        return False
+    else:
+        return bool(dataStr)
+
 ################################################################################
 # posix compatibility functions below
 ################################################################################

eric ide

mercurial