Show the type of children TLObjects on .stringify()

This commit is contained in:
Lonami Exo 2017-09-23 11:01:25 +02:00
parent 5701029fbf
commit 80e9877256

View File

@ -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,11 +44,12 @@ 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__)
children = obj.to_dict(recursive=False)
if children:
result.append(': ') result.append(': ')
result.append(TLObject.pretty_format( result.append(TLObject.pretty_format(
obj.to_dict(), indent obj.to_dict(recursive=False), indent
)) ))
elif isinstance(obj, dict): elif isinstance(obj, dict):
@ -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):