Example #1
0
 def get_relations(self, role_types: list = None):
     if not role_types:
         role_types = []
     return (concept_proto_reader.thing(r) for rp in self.stream(
         thing_get_relations_req(self.get_iid(),
                                 concept_proto_builder.types(role_types)))
             for r in rp.thing_get_relations_res_part.relations)
Example #2
0
    def get_players_by_role_type(self):
        stream = (
            role_player for res_part in self.stream(
                relation_get_players_by_role_type_req(self.get_iid()))
            for role_player in res_part.
            relation_get_players_by_role_type_res_part.role_types_with_players)

        role_player_dict = {}
        for role_player in stream:
            role = concept_proto_reader.type_(role_player.role_type)
            player = concept_proto_reader.thing(role_player.player)
            if role not in role_player_dict:
                role_player_dict[role] = []
            role_player_dict[role].append(player)
        return role_player_dict
Example #3
0
 def get_players(self, role_types=None):
     return (concept_proto_reader.thing(t) for rp in self.stream(
         relation_get_players_req(self.get_iid(),
                                  concept_proto_builder.types(role_types)))
             for t in rp.relation_get_players_res_part.things)
Example #4
0
 def get_owners(self, owner_type: ThingType = None):
     return (concept_proto_reader.thing(t) for rp in self.stream(attribute_get_owners_req(self.get_iid(), concept_proto_builder.thing_type(owner_type)))
             for t in rp.attribute_get_owners_res_part.things)
 def get_thing(self, iid: str):
     res = self.execute(concept_manager_get_thing_req(iid))
     return concept_proto_reader.thing(
         res.get_thing_res.thing) if res.get_thing_res.WhichOneof(
             "res") == "thing" else None
Example #6
0
 def get_instances(self):
     return (concept_proto_reader.thing(t) for rp in self.stream(
         thing_type_get_instances_req(self.get_label()))
             for t in rp.thing_type_get_instances_res_part.things)