def boolify(value, nullable=False, return_string=False):
 if isinstance(value, BOOL_COERCEABLE_TYPES):
  return bool(value)
 val = text_type(value).strip().lower().replace('.', '', 1)
 if val.isnumeric():
  return bool(float(val))
 elif (val in BOOLISH_TRUE):
  return True
 elif (nullable and (val in NULL_STRINGS)):
  return None
 elif (val in BOOLISH_FALSE):
  return False
 else:
  try:
   return bool(complex(val))
  except ValueError:
   if (isinstance(value, string_types) and return_string):
    return value
   raise TypeCoercionError(value, ('The value %r cannot be boolified.' % value))

def boolify ( value , nullable = False , return_string = False ) : if isinstance ( value , BOOL_COERCEABLE_TYPES ) : return bool ( value ) val = text_type ( value ) . strip ( ) . lower ( ) . replace ( '.' , '' , 1 ) if val . isnumeric ( ) : return bool ( float ( val ) ) elif ( val in BOOLISH_TRUE ) : return True elif ( nullable and ( val in NULL_STRINGS ) ) : return None elif ( val in BOOLISH_FALSE ) : return False else : try : return bool ( complex ( val ) ) except ValueError : if ( isinstance ( value , string_types ) and return_string ) : return value raise TypeCoercionError ( value , ( 'The value %r cannot be boolified.' % value ) )
function that will translate common strings into bool values true -> "true" .