Esempio n. 1
0
    def get_thing(self, iid: str):
        req = concept_proto.ConceptManager.Req()
        get_thing_req = concept_proto.ConceptManager.GetThing.Req()
        get_thing_req.iid = concept_proto_builder.iid(iid)
        req.get_thing_req.CopyFrom(get_thing_req)

        response = self._execute(req)
        return concept_proto_reader.thing(
            response.get_thing_res.thing) if response.get_thing_res.WhichOneof(
                "res") == "thing" else None
Esempio n. 2
0
 def _type_stream(self, method: concept_proto.Thing.Req,
                  type_list_getter: Callable[[concept_proto.Thing.Res],
                                             List[concept_proto.Type]]):
     method.iid = concept_proto_builder.iid(self.get_iid())
     request = transaction_proto.Transaction.Req()
     request.thing_req.CopyFrom(method)
     return map(
         lambda type_proto: concept_proto_reader.type_(type_proto),
         self._transaction._stream(
             request, lambda res: type_list_getter(res.thing_res)))
Esempio n. 3
0
    def get_players_by_role_type(self):
        method = concept_proto.Thing.Req()
        method.relation_get_players_by_role_type_req.CopyFrom(concept_proto.Relation.GetPlayersByRoleType.Req())
        method.iid = concept_proto_builder.iid(self.get_iid())

        request = transaction_proto.Transaction.Req()
        request.thing_req.CopyFrom(method)
        stream = self._transaction._stream(request, lambda res: res.thing_res.relation_get_players_by_role_type_res.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
Esempio n. 4
0
 def _execute(self, method: concept_proto.Thing.Req):
     method.iid = concept_proto_builder.iid(self.get_iid())
     request = transaction_proto.Transaction.Req()
     request.thing_req.CopyFrom(method)
     return self._transaction._execute(request).thing_res