mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Show the type of children TLObjects on .stringify()
This commit is contained in:
parent
5701029fbf
commit
80e9877256
|
@ -20,10 +20,13 @@ class TLObject:
|
||||||
"""
|
"""
|
||||||
if indent is None:
|
if indent is None:
|
||||||
if isinstance(obj, TLObject):
|
if isinstance(obj, TLObject):
|
||||||
return '{{{}: {}}}'.format(
|
children = obj.to_dict(recursive=False)
|
||||||
type(obj).__name__,
|
if children:
|
||||||
TLObject.pretty_format(obj.to_dict())
|
return '{}: {}'.format(
|
||||||
)
|
type(obj).__name__, TLObject.pretty_format(children)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return type(obj).__name__
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
return '{{{}}}'.format(', '.join(
|
return '{{{}}}'.format(', '.join(
|
||||||
'{}: {}'.format(
|
'{}: {}'.format(
|
||||||
|
@ -41,12 +44,13 @@ class TLObject:
|
||||||
else:
|
else:
|
||||||
result = []
|
result = []
|
||||||
if isinstance(obj, TLObject):
|
if isinstance(obj, TLObject):
|
||||||
result.append('{')
|
|
||||||
result.append(type(obj).__name__)
|
result.append(type(obj).__name__)
|
||||||
result.append(': ')
|
children = obj.to_dict(recursive=False)
|
||||||
result.append(TLObject.pretty_format(
|
if children:
|
||||||
obj.to_dict(), indent
|
result.append(': ')
|
||||||
))
|
result.append(TLObject.pretty_format(
|
||||||
|
obj.to_dict(recursive=False), indent
|
||||||
|
))
|
||||||
|
|
||||||
elif isinstance(obj, dict):
|
elif isinstance(obj, dict):
|
||||||
result.append('{\n')
|
result.append('{\n')
|
||||||
|
@ -81,7 +85,7 @@ class TLObject:
|
||||||
return ''.join(result)
|
return ''.join(result)
|
||||||
|
|
||||||
# These should be overrode
|
# These should be overrode
|
||||||
def to_dict(self):
|
def to_dict(self, recursive=True):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def on_send(self, writer):
|
def on_send(self, writer):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user