Returns any entities with the specified descriptor
174652
def with_descriptor(self, descriptor):
        '''
        
        '''
        res = {}
        desc = "%s_descriptor" % descriptor
        for eid, ent in self.items():
            if desc in ent:
                res[eid] = ent
        return res
1194670
@Nonnull
    public Descriptor getDescriptorOrDie(Class<? extends Describable> type) {
        Descriptor d = getDescriptor(type);
        if (d==null)
            throw new AssertionError(type+" is missing its descriptor");
        return d;
    }
1339900
def all_entity_classes():
    """"""
    persistent_classes = Entity._decl_class_registry.values()
    # with sqlalchemy 0.8 _decl_class_registry holds object that are not
    # classes
    return [
        cls for cls in persistent_classes if isclass(cls) and issubclass(cls, Entity)
    ]
783985
public function getDescriptorFor($entity)
    {
        return $this->descriptors->containsKey($entity)
            ? $this->descriptors->get($entity)
            : $this->createDescriptor($entity);
    }
68818
def get_entity_by_identifier(self, url: str, identifier: str) -> Optional[NamespaceEntry]:
        """"""
        entry_filter = and_(Namespace.url == url, NamespaceEntry.identifier == identifier)
        return self.session.query(NamespaceEntry).join(Namespace).filter(entry_filter).one_or_none()
169376
Optional<EntityDescriptor> referencingEntity(AttributeDescriptor attribute) {
        if (!Names.isEmpty(attribute.referencedTable())) {
            // match by table name
            return entities.values().stream()
                .filter(entity -> entity.tableName().equalsIgnoreCase(attribute.referencedTable()))
                .findFirst();

        } else if (!Names.isEmpty(attribute.referencedType())) {
            // match by type name
            Optional<TypeKind> primitiveType = Stream.of(TypeKind.values())
                .filter(TypeKind::isPrimitive)
                .filter(kind -> kind.toString().toLowerCase().equals(attribute.referencedType()))
                .findFirst();
            if (!primitiveType.isPresent()) {
                QualifiedName referencedType = new QualifiedName(attribute.referencedType());
                return entityByName(referencedType);
            } // else attribute is basic foreign key and not referring to an entity
        } else {
            TypeMirror referencedType = attribute.typeMirror();
            if (attribute.isIterable()) {
                referencedType = collectionElementType(referencedType);
            }
            TypeElement referencedElement = (TypeElement) types.asElement(referencedType);
            if (referencedElement != null) {
                String referencedName = referencedElement.getSimpleName().toString();
                return entities.values().stream()
                        .filter(entity -> match(entity, referencedName))
                        .findFirst();
            }
        }
        return Optional.empty();
    }
491191
def _find_entity(self, entity):
        ''' '''
        if entity in self.entities:
            return self.entities[entity]
        _ent = [e for e in self.entities.values() if e.name == entity]
        if len(_ent) > 1:
            raise ValueError("Entity name '%s' matches %d entities. To "
                             "avoid ambiguity, please prefix the entity "
                             "name with its domain (e.g., 'bids.%s'." %
                             (entity, len(_ent), entity))
        if _ent:
            return _ent[0]

        raise ValueError("No entity '%s' found." % entity)
456251
def get_entities_by_components(self, *components):
        '''
        
        '''
        return list(filter(lambda entity:
                           set(components) <=
                           set(map(type, entity.get_components())),
                           self._entities))
297040
protected function filterDescriptor(Descriptor $descriptor)
    {
        if (!$descriptor instanceof Filterable) {
            return $descriptor;
        }

        // filter the descriptor; this may result in the descriptor being removed!
        $descriptor = $this->filter($descriptor);
        if (!$descriptor) {
            return null;
        }

        return $descriptor;
    }
708541
function getDescriptorParts(lineDescriptor, descriptorFlags) {
  const descriptorParts = [];
  if (descriptorFlags.suite) {
    descriptorParts.push(lineDescriptor.suites.map(breakWords).join('\n'));
  }
  if (descriptorFlags.measurement) {
    descriptorParts.push(breakWords(lineDescriptor.measurement));
  }
  if (descriptorFlags.bot) {
    descriptorParts.push(lineDescriptor.bots.map(breakWords).join('\n'));
  }
  if (descriptorFlags.cases) {
    descriptorParts.push(lineDescriptor.cases.map(breakWords).join('\n'));
  }
  if (descriptorFlags.buildType) {
    descriptorParts.push(lineDescriptor.buildType);
  }
  return descriptorParts;
}
900446
def queryTypesDescriptions(self, types):
        
        types = list(types)
        if types:
            types_descs = self.describeSObjects(types)
        else:
            types_descs = []
        return dict(map(lambda t, d: (t, d), types, types_descs))
549477
def get_used_entities(self,use_specs):
        
        if len(use_specs.strip()) == 0:
            return (self.pub_procs, self.pub_absints, self.pub_types, self.pub_vars)
        only = bool(self.ONLY_RE.match(use_specs))
        use_specs = self.ONLY_RE.sub('',use_specs)
        ulist = self.SPLIT_RE.split(use_specs)
        ulist[-1] = ulist[-1].strip()
        uspecs = {}
        for item in ulist:
            match = self.RENAME_RE.search(item)
            if match:
                uspecs[match.group(1).lower()] = match.group(2)
            else:
                uspecs[item.lower()] = item
        ret_procs = {}
        ret_absints = {}
        ret_types = {}
        ret_vars = {}
        for name, obj in self.pub_procs.items():
            name = name.lower()
            if only:
                if name in uspecs:
                    ret_procs[name] = obj
            else:
                ret_procs[name] = obj
        for name, obj in self.pub_absints.items():
            name = name.lower()
            if only:
                if name in uspecs:
                    ret_absints[name] = obj
            else:
                ret_absints[name] = obj
        for name, obj in self.pub_types.items():
            name = name.lower()
            if only:
                if name in uspecs:
                    ret_types[name] = obj
            else:
                ret_types[name] = obj
        for name, obj in self.pub_vars.items():
            name = name.lower()
            if only:
                if name in uspecs:
                    ret_vars[name] = obj
            else:
                ret_vars[name] = obj
        return (ret_procs,ret_absints,ret_types,ret_vars)
741460
def _get_descriptors(self):
        
        rlist = []
        wlist = []
        xlist = []

        for socket, flags in self.sockets.items():
            if isinstance(socket, zmq.Socket):
                rlist.append(socket.getsockopt(zmq.FD))
                continue
            elif isinstance(socket, int):
                fd = socket
            elif hasattr(socket, 'fileno'):
                try:
                    fd = int(socket.fileno())
                except:
                    raise ValueError('fileno() must return an valid integer fd')
            else:
                raise TypeError('Socket must be a 0MQ socket, an integer fd '
                                'or have a fileno() method: %r' % socket)

            if flags & zmq.POLLIN:
                rlist.append(fd)
            if flags & zmq.POLLOUT:
                wlist.append(fd)
            if flags & zmq.POLLERR:
                xlist.append(fd)

        return (rlist, wlist, xlist)
273020
def entities(self, subject_id):
        
        res = self._cache.get(subject_id)
        if not res:
            raise KeyError("No such subject")
        else:
            return res
1358625
Set<AttributeDescriptor> mappedAttributes(EntityDescriptor entity,
                                              AttributeDescriptor attribute,
                                              EntityDescriptor referenced) {
        String mappedBy = attribute.mappedBy();
        if (Names.isEmpty(mappedBy)) {
            return referenced.attributes().stream()
                .filter(other -> other.cardinality() != null)
                .filter(other -> referencingEntity(other).isPresent())
                .filter(other -> referencingEntity(other)
                        .orElseThrow(IllegalStateException::new) == entity)
                .collect(Collectors.toSet());
        } else {
            return referenced.attributes().stream()
                .filter(other -> other.name().equals(mappedBy))
                .collect(Collectors.toSet());
        }
    }
418108
def get_entities_for_reindex(tags):
    """"""
    if isinstance(tags, Tag):
        tags = (tags,)

    session = db.session()
    indexing = get_service("indexing")
    tbl = Entity.__table__
    tag_ids = [t.id for t in tags]
    query = (
        sa.sql.select([tbl.c.entity_type, tbl.c.id])
        .select_from(tbl.join(entity_tag_tbl, entity_tag_tbl.c.entity_id == tbl.c.id))
        .where(entity_tag_tbl.c.tag_id.in_(tag_ids))
    )

    entities = set()

    with session.no_autoflush:
        for entity_type, entity_id in session.execute(query):
            if entity_type not in indexing.adapted:
                logger.debug("%r is not indexed, skipping", entity_type)

            item = ("changed", entity_type, entity_id, ())
            entities.add(item)

    return entities
395631
def _get_entities(self, user, ids):
        """"""
        queryset = get_objects_for_user(user, 'view_entity', Entity.objects.filter(id__in=ids))
        actual_ids = queryset.values_list('id', flat=True)
        missing_ids = list(set(ids) - set(actual_ids))
        if missing_ids:
            raise exceptions.ParseError(
                "Entities with the following ids not found: {}" .format(', '.join(map(str, missing_ids)))
            )

        return queryset