From cffafa8c611db20469d81c641bf1eb18d43811b3 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 16 Dec 2018 17:10:08 +0100 Subject: [PATCH] Small fixed to PyrogramType --- pyrogram/client/types/pyrogram_type.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/types/pyrogram_type.py b/pyrogram/client/types/pyrogram_type.py index 20b476a2..ee0cfea4 100644 --- a/pyrogram/client/types/pyrogram_type.py +++ b/pyrogram/client/types/pyrogram_type.py @@ -24,6 +24,9 @@ class PyrogramType: def __str__(self): return dumps(self, cls=Encoder, indent=4) + def __getitem__(self, item): + return getattr(self, item) + def remove_none(obj): if isinstance(obj, (list, tuple, set)): @@ -37,8 +40,4 @@ def remove_none(obj): class Encoder(JSONEncoder): def default(self, o: PyrogramType): content = {i: getattr(o, i) for i in filter(lambda x: not x.startswith("_"), o.__dict__)} - - return OrderedDict( - [("_", "pyrogram:{}".format(o.__class__.__name__))] - + [i for i in remove_none(content).items()] - ) + return remove_none(OrderedDict([("_", "pyrogram:" + o.__class__.__name__)] + [i for i in content.items()]))