Helper to get entities for a given type.
552530
def __get_entities(self, etype):
        """"""
        r = fapi.get_entities(self.namespace, self.name,
                              etype, self.api_url)
        fapi._check_response_code(r, 200)
        return [Entity(e['entityType'], e['name'], e['attributes'])
                for e in r.json()]
1233663
def get_entity(self, etype, entity_id):
        
        r = fapi.get_entity(self.namespace, self.name, etype,
                               entity_id, self.api_url)
        fapi._check_response_code(r, 200)
        dresp = r.json()
        return Entity(etype, entity_id, dresp['attributes'])
327474
public function getEntities($type = false, $offset = 0, $limit = 1000, $details = "on") {
        if ($type) {
            $url = $this->url . "contextTypes/" . $type;
        } else {
            $url = $this->url . "contextEntities/";
        }

        $ret = $this->restRequest($url . "?offset=$offset&limit=$limit&details=$details", 'GET')->getResponseBody();
        $Context = (new Context\Context($ret))->get();
        $Entities = [];
        
        if($Context instanceof \stdClass && isset($Context->errorCode)){
            switch ((int) $Context->errorCode->code) {
                case 404:
                case 500:
                    throw new Exception\GeneralException($Context->errorCode->reasonPhrase,(int)$Context->errorCode->code, null, $ret);
                default:
                case 200:
                    break;
            }
        }else{
            throw new Exception\GeneralException("Malformed Orion Response",500, null, $ret);
        }
        
        if(isset($Context->contextResponses) && count($Context->contextResponses) > 0){
            foreach ($Context->contextResponses as $entity) {
                $t = $entity->contextElement->type;
                $id = $entity->contextElement->id;
                
                if(!array_key_exists($t, $Entities)){
                    $Entities[$t] = [];
                }
                $Entities[$t][$id] = $entity->contextElement->attributes;
            }
        }




        return new Context\Context($Entities);
    }
581070
def entities(self):
    """"""
    start = 0
    end = 0
    prev_tag = u'O'
    chunks = []
    for i, (w, tag) in enumerate(self.ne_chunker.annotate(self.words)):
      if tag != prev_tag:
        if prev_tag == u'O':
          start = i
        else:
          chunks.append(Chunk(self.words[start: i], start, i, tag=prev_tag,
                              parent=self))
        prev_tag = tag
    if tag != u'O':
      chunks.append(Chunk(self.words[start: i+1], start, i+1, tag=tag,
                          parent=self))
    return chunks
331463
def get_fields(self):
        """"""
        fields = super(DataSerializer, self).get_fields()

        # Hide collections/entities fields on list views as fetching them may be expensive.
        if self.parent is not None:
            del fields['collections']
            del fields['entities']

        return fields
1185530
def get_entity_names(self, data):
        """"""
        entities = self._filter_queryset('view_entity', data.entity_set.all())
        return list(entities.values_list('name', flat=True))
259653
def db_type(cls, dtype):
        """"""
        if isinstance(dtype, ExtensionDtype):
            return cls.type_map.get(dtype.kind)
        elif hasattr(dtype, 'char'):
            return cls.type_map.get(dtype.char)
207903
def get_entity(self, uri: str) -> OntologyClass:
        
        return self.entities.get(str(uri), None)
717090
def get_possible_types(
        self, abstract_type: GraphQLAbstractType
    ) -> Sequence[GraphQLObjectType]:
        """"""
        if is_union_type(abstract_type):
            abstract_type = cast(GraphQLUnionType, abstract_type)
            return abstract_type.types
        return self._implementations[abstract_type.name]
65247
def fetch_entities(self):
        """"""
        query = text(
            """
            SELECT entity_id
            FROM states
            GROUP BY entity_id
            """
        )
        response = self.perform_query(query)

        # Parse the domains from the entities.
        entities = {}
        domains = set()

        for [entity] in response:
            domain = entity.split(".")[0]
            domains.add(domain)
            entities.setdefault(domain, []).append(entity)

        self._domains = list(domains)
        self._entities = entities
        print("There are {} entities with data".format(len(entities)))
933652
def get_any_entity(self, id=None, uri=None, match=None):
        

        if not id and not uri and not match:
            return None

        if type(id) == type("string"):
            uri = id
            id = None
            if not is_http(uri):
                match = uri
                uri = None
        if match:
            if type(match) != type("string"):
                return []
            res = []
            if ":" in match:  # qname
                for x in self.all_classes:
                    if match.lower() in x.qname.lower():
                        res += [x]
                for x in self.all_properties:
                    if match.lower() in x.qname.lower():
                        res += [x]
            else:
                for x in self.all_classes:
                    if match.lower() in x.uri.lower():
                        res += [x]
                for x in self.all_properties:
                    if match.lower() in x.uri.lower():
                        res += [x]
            return res
        else:
            for x in self.all_classes:
                if id and x.id == id:
                    return x
                if uri and x.uri.lower() == uri.lower():
                    return x
            for x in self.all_properties:
                if id and x.id == id:
                    return x
                if uri and x.uri.lower() == uri.lower():
                    return x
            return None
379140
def _get_components(self, *component_types: Type)-> Iterable[Tuple[int, ...]]:
        
        entity_db = self._entities
        comp_db = self._components

        try:
            for entity in set.intersection(*[comp_db[ct] for ct in component_types]):
                yield entity, [entity_db[entity][ct] for ct in component_types]
        except KeyError:
            pass
1051975
def _get_type(cls, ptr):
        """"""

        # fall back to the base class if unknown
        return cls.__types.get(lib.g_base_info_get_type(ptr), cls)
226131
def get_object_or_child_by_type(self, *types):
        

        objects = self.get_objects_or_children_by_type(*types)
        return objects[0] if any(objects) else None
809175
def _live_entity_map(self, entity_type):
        
        return {
            entity_id: self.get_entity(entity_type, entity_id)
            for entity_id, history in self.state.get(entity_type, {}).items()
            if history[-1] is not None
        }
488719
def entities(self):
        """"""
        r = fapi.get_entities_with_type(self.namespace,
                                        self.name, self.api_url)
        fapi._check_response_code(r, 200)
        edicts = r.json()
        return [Entity(e['entityType'], e['name'], e['attributes'])
                for e in edicts]
799986
def _get_component(self, component_type: Type[C]) -> Iterable[Tuple[int, C]]:
        
        entity_db = self._entities

        for entity in self._components.get(component_type, []):
            yield entity, entity_db[entity][component_type]