[Dev OpenGP] [78] Convert string to bool

[ Thread Index | Date Index | More opengp.tuxfamily.org/development Archives ]


Revision: 78
Author:   alband85
Date:     2009-03-24 14:34:17 +0100 (Tue, 24 Mar 2009)

Log Message:
-----------
Convert string to bool

Added Paths:
-----------
    trunk/src/lib/ogp/misc/
    trunk/src/lib/ogp/misc/__init__.py


Added: trunk/src/lib/ogp/misc/__init__.py
===================================================================
--- trunk/src/lib/ogp/misc/__init__.py	                        (rev 0)
+++ trunk/src/lib/ogp/misc/__init__.py	2009-03-24 13:34:17 UTC (rev 78)
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*
+
+def smart_bool(s):
+	if s is True or s is False:
+		return s
+	else:
+		s = str(s).strip().lower()
+		return not s in ['false','f','n','0','']


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/