@staticmethod<EOL><INDENT>def to_bool(value, do_raise=True):<DEDENT>
value = value.lower()<EOL>if value.isdigit():<EOL><INDENT>return bool(int(value))<EOL><DEDENT>if value in _str_true:<EOL><INDENT>return True<EOL><DEDENT>elif value in _str_false:<EOL><INDENT>return False<EOL><DEDENT>if do_raise:<EOL><INDENT>raise ValueError("<STR_LIT>" % value)<EOL><DEDENT>return False<EOL>
Convert a string to a boolean value.

        If the string consists of digits, the integer value of the string
        is coerced to a boolean value.  Otherwise, any of the strings "t",
        "true", "on", "y", and "yes" are considered True and any of the
        strings "f", "false", "off", "n", and "no" are considered False.
        A ValueError will be raised for any other value.