mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Consider vector attributes for get_input_* utils (closes #166)
This commit is contained in:
parent
5ded836437
commit
cfea0f80da
|
@ -322,19 +322,15 @@ class TLGenerator:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError('Cannot infer a value for ', arg)
|
raise ValueError('Cannot infer a value for ', arg)
|
||||||
|
|
||||||
|
# Well-known cases, auto-cast it to the right type
|
||||||
elif arg.type == 'InputPeer' and tlobject.is_function:
|
elif arg.type == 'InputPeer' and tlobject.is_function:
|
||||||
# Well-known case, auto-cast it to the right type
|
TLGenerator.write_get_input(builder, arg, 'get_input_peer')
|
||||||
builder.writeln(
|
|
||||||
'self.{0} = get_input_peer({0})'.format(arg.name)
|
|
||||||
)
|
|
||||||
elif arg.type == 'InputChannel' and tlobject.is_function:
|
elif arg.type == 'InputChannel' and tlobject.is_function:
|
||||||
builder.writeln(
|
TLGenerator.write_get_input(builder, arg, 'get_input_channel')
|
||||||
'self.{0} = get_input_channel({0})'.format(arg.name)
|
|
||||||
)
|
|
||||||
elif arg.type == 'InputUser' and tlobject.is_function:
|
elif arg.type == 'InputUser' and tlobject.is_function:
|
||||||
builder.writeln(
|
TLGenerator.write_get_input(builder, arg, 'get_input_user')
|
||||||
'self.{0} = get_input_user({0})'.format(arg.name)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
builder.writeln('self.{0} = {0}'.format(arg.name))
|
builder.writeln('self.{0} = {0}'.format(arg.name))
|
||||||
|
|
||||||
|
@ -434,6 +430,22 @@ class TLGenerator:
|
||||||
builder.writeln('return MTProtoRequest.pretty_format(self, indent=0)')
|
builder.writeln('return MTProtoRequest.pretty_format(self, indent=0)')
|
||||||
# builder.end_block() # No need to end the last block
|
# builder.end_block() # No need to end the last block
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def write_get_input(builder, arg, get_input_code):
|
||||||
|
"""Returns "True" if the get_input_* code was written when assigning
|
||||||
|
a parameter upon creating the request. Returns False otherwise
|
||||||
|
"""
|
||||||
|
if arg.is_vector:
|
||||||
|
builder.writeln(
|
||||||
|
'self.{0} = [{1}({0}_item) for {0}_item in {0}]'
|
||||||
|
.format(arg.name, get_input_code)
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
builder.writeln(
|
||||||
|
'self.{0} = {1}({0})'.format(arg.name, get_input_code)
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_class_name(tlobject):
|
def get_class_name(tlobject):
|
||||||
"""Gets the class name following the Python style guidelines, in ThisClassFormat"""
|
"""Gets the class name following the Python style guidelines, in ThisClassFormat"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user