示例#1
0
class Group:
    def __init__(self, id_: int, data: GroupData) -> None:
        self.data = data
        self.peer = Peer(id_, PeerType.PEERTYPE_GROUP)

    @classmethod
    def from_api(cls, group: groups_pb2.Group) -> 'Group':
        return cls(group.id, GroupData.from_api(group.data))

    def __dict__(self):
        return {"data": self.data.__dict__(), "peer": self.peer.__dict__()}

    def __str__(self):
        return "Group({})".format(self.__dict__())
示例#2
0
class User:
    def __init__(self, id: int, data: UserData = None) -> None:
        self.data = data
        self.peer = Peer(id, PeerType.PEERTYPE_PRIVATE)

    @classmethod
    def from_api(cls, user: users_pb2.User) -> 'User':
        return cls(user.id, UserData.from_api(user.data))

    def __dict__(self):
        return {"data": self.data.__dict__(), "peer": self.peer.__dict__()}

    def __str__(self):
        return "User({})".format(self.__dict__())