String to Boolean Common Tools Mixin

* used for converting boolean strings to booleans

Change-Id: If82273438910e03ebd4f8ca2cb1060c47ee25c91
This commit is contained in:
Franklin Naval
2014-05-14 10:19:37 -05:00
parent 0d3d333cee
commit 6f9501117b

View File

@@ -30,6 +30,19 @@ class CommonToolsMixin(object):
return true_string if value is True else false_string
return value
@staticmethod
def _string_to_bool(boolean_string):
"""Returns a boolean value of a boolean value string representation
"""
if boolean_string.lower() == "true":
return True
elif boolean_string.lower() == "false":
return False
else:
raise ValueError(
msg="Passed in boolean string was neither True or False: {0}"
.format(boolean_string))
@staticmethod
def _remove_empty_values(dictionary):
"""Returns a new dictionary based on 'dictionary', minus any keys with