Return True if yes, False if no, or the default.
969408
def filter_yn(string, default=None):
    """"""
    if string.startswith(('Y', 'y')):
        return True
    elif string.startswith(('N', 'n')):
        return False
    elif not string and default is not None:
        return True if default else False
    raise InvalidInputError
158425
def check(self, options=None):
        """"""
        self.check_values(options)
        self.check_attributes(options)
        self.check_values(options)
        return self
323434
def ask_yes_no(*question: Token, default: bool = False) -> bool:
    """"""
    while True:
        tokens = [green, "::", reset] + list(question) + [reset]
        if default:
            tokens.append("(Y/n)")
        else:
            tokens.append("(y/N)")
        info(*tokens)
        answer = read_input()
        if answer.lower() in ["y", "yes"]:
            return True
        if answer.lower() in ["n", "no"]:
            return False
        if not answer:
            return default
        warning("Please answer by 'y' (yes) or 'n' (no) ")
750314
def str2bool(value):
    """"""
    if value.lower() in ('yes', 'true', 't', 'y', '1'):
        return True
    if value.lower() in ('no', 'false', 'f', 'n', '0'):
        return False
    if value.lower() in ('d', 'default', ''):
        return None
    raise argparse.ArgumentTypeError('Expected: (Y)es/(T)rue/(N)o/(F)alse/(D)efault')
1069879
def default(self):
        """"""

        if self._default is None or self._default not in self:
            self._default = list(self.keys())[0] if self else None

        return self._default
1248239
def confirm(question, default=True):
    
    valid = {"": default, "yes": True, "y": True, "no": False, "n": False}
    while 1:
        choice = input(question + (" [Y/n] " if default else " [y/N] ")).lower()
        if choice in valid:
            return valid[choice]
        print("Please respond with 'y' or 'n' ")
371124
def validate_boolean_or_string(option, value):
    """"""
    if isinstance(value, string_type):
        if value not in ('true', 'false'):
            raise ValueError("The value of %s must be "
                             "'true' or 'false'" % (option,))
        return value == 'true'
    return validate_boolean(option, value)
465535
def DEFINE_bool(self, name, default, help, constant=False):
    """"""
    self.AddOption(
        type_info.Bool(name=name, default=default, description=help),
        constant=constant)
1053311
def _to_bool(value):
        """"""
        bool_value = False
        if str(value).lower() in ['1', 'true']:
            bool_value = True
        return bool_value
276420
def arg_bool(name, default=False):
    
    v = request.args.get(name, '')
    if not len(v):
        return default
    return v in BOOL_TRUISH
1229879
def confirm(question):
    
    if FORCE_YES:
        return True

    while True:
        answer = input(question + ' <Yes|No>').lower()

        if answer == 'yes' or answer == 'y':
            confirmed = True
            break
        if answer == 'no' or answer == 'n':
            confirmed = False
            break

    return confirmed
382934
def getbool(key, default=False):
    
    value = os.getenv(key)
    if value and value.lower() in ('true', '1'):
        value = True
    elif value and value.lower() in ('false', '0'):
        value = False
    else:
        value = default
    return value
64465
def to_bool_alt(value):
    '''
    
    '''
    value = from_bool_alt(value)
    if isinstance(value, bool):
        value = 'yes' if value else 'no'
    elif value is None:
        value = 'none'

    return value
626377
def _parse_bool_default_value(property_name, default_value_string):
    """"""
    lowercased_value_string = default_value_string.lower()
    if lowercased_value_string in {'0', 'false'}:
        return False
    elif lowercased_value_string in {'1', 'true'}:
        return True
    else:
        raise AssertionError(u'Unsupported default value for boolean property "{}": '
                             u'{}'.format(property_name, default_value_string))
1104417
def validate_bool(b):
    """"""
    if isinstance(b, six.string_types):
        b = b.lower()
    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True):
        return True
    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False):
        return False
    else:
        raise ValueError('Could not convert "%s" to boolean' % b)
1365257
def to_bool(x):
    """""""
    if isinstance(x, bool):
        return x
    elif isinstance(x, str):
        return False if x.lower() in _FALSES else True
    else:
        return bool(x)
896145
def is_default(self):
        
        for _, item in self.iter_items(recursive=True):
            if not item.is_default:
                return False
        return True