summaryrefslogtreecommitdiffstats
path: root/pykolab/utils.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-10 17:03:32 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-10 17:03:32 +0000
commita70c6d6fc211fab8f0329c3bccc0c136e552738c (patch)
tree2fa44c77679f4d2fc6f9c1b22c954bcb7767cf3e /pykolab/utils.py
parent0d49633f453164fffc03fd62460b1b39a7cfe5a4 (diff)
downloadpykolab-a70c6d6fc211fab8f0329c3bccc0c136e552738c.tar.gz
Supply your very basic "does this value represent True or False?" function
Diffstat (limited to 'pykolab/utils.py')
-rw-r--r--pykolab/utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py
index d4b1a09..a4d8455 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -368,6 +368,26 @@ def translate(mystring, locale_name='en_US'):
return result
+def true_or_false(val):
+ if val == None:
+ return False
+
+ if isinstance(val, bool):
+ return val
+
+ if isinstance(val, basestring) or isinstance(val, str):
+ val = val.lower()
+ if val in [ "true", "yes", "y" ]:
+ return True
+ else:
+ return False
+
+ if isinstance(val, int) or isinstance(val, float):
+ if val >= 1:
+ return True
+ else:
+ return False
+
def is_service(services):
"""
Checks each item in list services to see if it has a RC script in