Accept both booleans and CLIFilters as input and
    turn it into a CLIFilter.
12007
def to_cli_filter(bool_or_filter):
    
    if not isinstance(bool_or_filter, (bool, CLIFilter)):
        raise TypeError('Expecting a bool or a CLIFilter instance. Got %r' % bool_or_filter)

    return {
        True: _always,
        False: _never,
    }.get(bool_or_filter, bool_or_filter)
1156231
function toBoolean(value)
    {
        var result = { "true" : true, "false" : false }[value];
        return result == null ? value : result;
    }
1207078
def bool_input(message):
    '''
    
    '''

    while True:
        suffix = ' (true or false): '
        inp = input(message + suffix)
        if inp.lower() == 'true':
            return True
        elif inp.lower() == 'false':
            return False
        else:
            print(colored('Must be either true or false, try again!', 'red'))
282341
def accept(self, f, *args):
        """"""
        match = self.match(f, *args)
        if match is None:
            return

        self.tokenizer.skip(len(match.tokens))
        return match
958232
def Compile(self, filter_implemention):
    """"""
    operator = self.operator.lower()
    if operator == "and" or operator == "&&":
      method = "AndFilter"
    elif operator == "or" or operator == "||":
      method = "OrFilter"
    else:
      raise ParseError("Invalid binary operator %s" % operator)

    args = [x.Compile(filter_implemention) for x in self.args]
    return filter_implemention.FILTERS[method](arguments=args)
481755
def validate(self):
        
        super(BoolFilter, self).validate()

        self._value = truth(str(self._value), self._condition)
        self._condition = "yes" if self._value else "no"
466727
def booleanize(truthy):
    '''
    
    '''
    if truthy is None:
        return False
    elif isinstance(truthy, basestring):
        if truthy:
            try:
                return bool(distutils.util.strtobool(truthy))
            except ValueError:
                return True
        else:
            return False
    elif is_collection(truthy):
        return not is_empty(truthy)
    else:
        return bool(truthy)
305896
private Boolean[] asBooleans( List<Object> values ) {
        ValueFactory<Boolean> factory = valueFactories.getBooleanFactory();
        Boolean[] res = new Boolean[values.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = factory.create(values.get(i));
        }
        return res;
    }
1135195
def asbool(value, true=(b'true', u'true'), false=(b'false', u'false')):
    
    value = value.strip().lower()
    if value in true:  # might raise UnicodeWarning/BytesWarning
        return True
    if value in false:
        return False
    raise TypeError()
22894
def _convert_simple_value_boolean_query_to_and_boolean_queries(tree, keyword):
    """"""

    def _create_operator_node(value_node):
        """Creates a KeywordOp or a ValueOp node."""
        base_node = value_node.op if isinstance(value_node, NotOp) else value_node
        updated_base_node = KeywordOp(keyword, base_node) if keyword else ValueOp(base_node)

        return NotOp(updated_base_node) if isinstance(value_node, NotOp) else updated_base_node

    def _get_bool_op_type(bool_op):
        return AndOp if isinstance(bool_op, And) else OrOp

    new_tree_root = _get_bool_op_type(tree.bool_op)(None, None)
    current_tree = new_tree_root
    previous_tree = tree

    while True:  # Walk down the tree while building the new AndOp queries subtree.
        current_tree.left = _create_operator_node(previous_tree.left)

        if not isinstance(previous_tree.right, SimpleValueBooleanQuery):
            current_tree.right = _create_operator_node(previous_tree.right)
            break

        previous_tree = previous_tree.right
        current_tree.right = _get_bool_op_type(previous_tree.bool_op)(None, None)
        current_tree = current_tree.right

    return new_tree_root
996542
def convertToBool():
    
    if not OPTIONS.strictBool.value:
        return []

    REQUIRES.add('strictbool.asm')

    result = []
    result.append('pop af')
    result.append('call __NORMALIZE_BOOLEAN')
    result.append('push af')

    return result
747148
def apply(self, search, field, value):
        """"""
        if not isinstance(value, list):
            value = [x for x in value.strip().split(',') if x]

        filters = [Q('match', **{field: item}) for item in value]
        return search.query('bool', should=filters)
94195
def pybool(v_str, strict_logical=True):
    """"""
    assert isinstance(v_str, str)
    assert isinstance(strict_logical, bool)

    if strict_logical:
        v_bool = v_str.lower()
    else:
        try:
            if v_str.startswith('.'):
                v_bool = v_str[1].lower()
            else:
                v_bool = v_str[0].lower()
        except IndexError:
            raise ValueError('{0} is not a valid logical constant.'
                             ''.format(v_str))

    if v_bool in ('.true.', '.t.', 'true', 't'):
        return True
    elif v_bool in ('.false.', '.f.', 'false', 'f'):
        return False
    else:
        raise ValueError('{0} is not a valid logical constant.'.format(v_str))
17220
def input(self, _in, out, **kw):
        """"""
        args = [self.binary or 'cleancss'] + self.rebase_opt
        if self.extra_args:
            args.extend(self.extra_args)
        self.subprocess(args, out, _in)
120336
def _applyFilter(lst, filterMethod, filterArgs):
        '''
            
        '''
        if filterMethod == FILTER_METHOD_AND:
            return lst.filterAnd(**filterArgs)
        else: # ALready validated in addFIlter that type is AND or OR
            return lst.filterOr(**filterArgs)
1347247
def from_bool(value):
    '''
    
    '''
    if value in ['on', 'yes']:
        value = True
    elif value in ['off', 'no']:
        value = False
    elif value == 'none':
        value = None

    return value
665689
def __convert_bool(node):
    """"""
    converted = __convert_node(node, default_value='true')

    # Check for a switch for reversing the value
    reverse_switch = __get_attribute(node, 'ReverseSwitch')

    if reverse_switch:
        converted_reverse = copy.deepcopy(converted)

        converted_reverse['switch'] = reverse_switch
        converted_reverse['value'] = 'false'

        return [converted_reverse, converted]

    # Modify flags when there is an argument child
    __with_argument(node, converted)

    return __check_for_flag(converted)