Finds all checks for a given entity with attributes matching
        ``**kwargs``.

        This isn't very efficient: it loads the entire list then filters on
        the Python side.
540552
def find_all_checks(self, **kwargs):
        
        found = []
        searches = kwargs.items()
        for obj in self.list():
            try:
                if all(getattr(obj, attr) == value
                        for (attr, value) in searches):
                    found.append(obj)
            except AttributeError:
                continue
        return found
1172030
def get_query_kwargs(**kwargs):
    """"""
    query_kwargs = {}

    query = kwargs.pop("query")
    if query:
        query_kwargs["query"] = query

    return query_kwargs
314565
def find_checks(argument_name):
    
    checks = []
    function_type = type(find_checks)
    for name, function in globals().iteritems():
        if type(function) is function_type:
            args = inspect.getargspec(function)[0]
            if len(args) >= 1 and args[0].startswith(argument_name):
                checks.append((name, function, args))
    checks.sort()
    return checks
1109257
def find_by(cls, **kwargs) -> 'Entity':
        
        logger.debug(f'Lookup `{cls.__name__}` object with values '
                     f'{kwargs}')

        # Find this item in the repository or raise Error
        results = cls.query.filter(**kwargs).limit(1).all()

        if not results:
            raise ObjectNotFoundError(
                f'`{cls.__name__}` object with values {[item for item in kwargs.items()]} '
                f'does not exist.')

        # Return the first result
        return results.first
1270380
def __args_check(self, valid, args=None, kwargs=None):
        '''
        
        '''
        if not isinstance(valid, list):
            valid = [valid]
        for cond in valid:
            if not isinstance(cond, dict):
                # Invalid argument
                continue
            # whitelist args, kwargs
            cond_args = cond.get('args', [])
            good = True
            for i, cond_arg in enumerate(cond_args):
                if args is None or len(args) <= i:
                    good = False
                    break
                if cond_arg is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(cond_arg, six.text_type(args[i])):
                    good = False
                    break
            if not good:
                continue
            # Check kwargs
            cond_kwargs = cond.get('kwargs', {})
            for k, v in six.iteritems(cond_kwargs):
                if kwargs is None or k not in kwargs:
                    good = False
                    break
                if v is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(v, six.text_type(kwargs[k])):
                    good = False
                    break
            if good:
                return True
        return False
461815
def get_filter(self, **filter_kwargs):
        

        q_objects = super(ListView, self).get_filter(**filter_kwargs)
        form = self.get_filter_form()
        if form:
            q_objects.extend(form.get_filter())

        return q_objects
162728
def all_entities(self, is_active=True):
        
        return self.get_all_entities(return_models=True, is_active=is_active)
289453
def get_filter_kwargs(self):
        
        if self.is_valid():
            filter_kwargs = {}
            for field in self.get_filter_fields():
                empty_values = EMPTY_VALUES
                if hasattr(self.fields[field], 'empty_values'):
                    empty_values = self.fields[field].empty_values

                value = self.cleaned_data.get(field)
                if not value in empty_values:
                    if self.search_fields and field in self.search_fields:
                        filter_kwargs["%s__icontains" % field] = value
                    else:
                        filter_kwargs[field] = value
            return filter_kwargs
        else:
            return {}
723916
def get_entity_by_tag(self, tag):
        '''
        
        '''
        matching_entities = list(filter(lambda entity: entity.get_tag() == tag,
                                        self._entities))
        if matching_entities:
            return matching_entities[0]
        else:
            return None
1366617
def filter_match_kwargs(kwargs, children=False):
    
    kwargs = kwargs.copy()
    for key in ('pattern', 'start', 'end', 'parent', 'formatter', 'value'):
        if key in kwargs:
            del kwargs[key]
    if children:
        for key in ('name',):
            if key in kwargs:
                del kwargs[key]
    return kwargs
814594
def filterKWArgsForFunc(kwargs, f):
    ''''''
    return dict([(k, v) for k, v in kwargs.iteritems() if k in _getValidArgList(f)])
1023275
def filter(self, *args, **kwargs):
		""""""
		if 'pk' in kwargs or 'id' in kwargs:
			return self.all_with_deleted().filter(*args, **kwargs)
		return self.get_query_set().filter(*args, **kwargs)
706704
def filtered(self, *, type_=None, lang=None, attrs={}):
        
        return list(self.filter(type_=type_, lang=lang, attrs=attrs))
1303468
public List<Entity> find(Entity where) throws SQLException {
		return find(where.getFieldNames(), where, EntityListHandler.create());
	}
583313
private boolean hasAttributeThatReferences(EntityType candidate, String entityTypeId) {
    Iterable<Attribute> attributes = candidate.getOwnAtomicAttributes();
    return stream(attributes)
        .filter(Attribute::hasRefEntity)
        .map(attribute -> attribute.getRefEntity().getId())
        .anyMatch(entityTypeId::equals);
  }
1033914
def check_arguments(self, **kwargs):
        
        for key in kwargs:
            if key in self._rules:
                for val in kwargs[key]:
                    self._rules[key](val)
            else:
                raise LookupError("Rule for {} does not exist. Make sure the rule starts with 'rule_'".format(key))
796953
@SuppressWarnings("unchecked")
	public <T> List<T> findAll(Class<T> entity) {
		if (entity == null) {
			throw new ApitraryOrmException("Cannot access null entity");
		}

		log.debug("Loading all " + entity.getName());

		QueriedGetRequest request = new QueriedGetRequest();
		request.setEntity(resolveApitraryEntity(entity));
		QueriedGetResponse response = resolveApitraryClient().send(request);

		if (HttpStatus.OK.ordinal() == response.getStatusCode()) {
			return (List<T>) new QueriedGetResponseUnmarshaller(this).unMarshall(response, entity);
		} else {
			/*
			 * happens more often than expected...
			 */
			// if(HttpStatus.Internal_Server_Error.ordinal() ==
			// response.getStatusCode()){
			// throw new
			// CommunicationErrorException(HttpStatus.Internal_Server_Error);
			// }
			throw new CommunicationErrorException(HttpStatus.getStatus(response.getStatusCode()), response.getResult());
		}
	}