devtools/dataimport.py
branchstable
changeset 4613 141a4f613f8a
parent 4527 67ab70e98488
child 4721 8f63691ccb7f
--- a/devtools/dataimport.py	Wed Feb 17 13:23:36 2010 +0100
+++ b/devtools/dataimport.py	Wed Feb 17 10:39:35 2010 +0100
@@ -134,7 +134,7 @@
         try:
             for func in funcs:
                 res[dest] = func(res[dest])
-            if res[dest] is None or res[dest]==False:
+            if res[dest] is None:
                 raise AssertionError('undetermined value')
         except AssertionError, err:
             if optional in funcs:
@@ -220,7 +220,26 @@
     return txt.strip()
 
 def yesno(value):
-    return value.lower()[0] in 'yo1'
+    """simple heuristic that returns boolean value
+
+    >>> yesno("Yes")
+    True
+    >>> yesno("oui")
+    True
+    >>> yesno("1")
+    True
+    >>> yesno("11")
+    True
+    >>> yesno("")
+    False
+    >>> yesno("Non")
+    False
+    >>> yesno("blablabla")
+    False
+    """
+    if value:
+        return value.lower()[0] in 'yo1'
+    return False
 
 def isalpha(value):
     if value.isalpha():