From 34343acba97f41535b2e75866f99d58e44da088d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 22 Mar 2012 17:32:31 -0400 Subject: Make 'yes' also a true boolean Adds yes, Yes, and all other capitalizations as a true boolean. Updated unit tests to test for these. Change-Id: I97915f870dd6bba612f74f0ceb78f2399fd81a93 --- openstack/common/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openstack') diff --git a/openstack/common/utils.py b/openstack/common/utils.py index 8cc400a..0191036 100644 --- a/openstack/common/utils.py +++ b/openstack/common/utils.py @@ -55,7 +55,7 @@ def bool_from_string(subject): Interpret a string as a boolean. Any string value in: - ('True', 'true', 'On', 'on', '1') + ('True', 'true', 'On', 'on', 'Yes', 'yes', '1') is interpreted as a boolean True. Useful for JSON-decoded stuff and config file parsing @@ -63,7 +63,7 @@ def bool_from_string(subject): if isinstance(subject, bool): return subject if isinstance(subject, basestring): - if subject.strip().lower() in ('true', 'on', '1'): + if subject.strip().lower() in ('true', 'on', 'yes', '1'): return True return False -- cgit