186 auth = await self.client(ExportAuthorizationRequest(self.dc_id))
187 self.client._init_request.query = ImportAuthorizationRequest(id=auth.id,
188 bytes=auth.bytes)
189 req = InvokeWithLayerRequest(LAYER, self.client._init_request)190 await sender.send(req)
191 self.auth_key = sender.auth_key
192 return sender
184 if not self.auth_key:
185 log.debug(f"Exporting auth to DC {self.dc_id}")
186 auth = await self.client(ExportAuthorizationRequest(self.dc_id))
187 self.client._init_request.query = ImportAuthorizationRequest(id=auth.id,188 bytes=auth.bytes)
189 req = InvokeWithLayerRequest(LAYER, self.client._init_request)
190 await sender.send(req)
96 self.request.bytes = data
97 log.debug(f"Sending file part {self.request.file_part}/{self.part_count}"
98 f" with {len(data)} bytes")
99 await self.client._call(self.sender, self.request)100 self.request.file_part += self.stride
101
102 async def disconnect(self) -> None:
54 async def next(self) -> Optional[bytes]:
55 if not self.remaining:
56 return None
57 result = await self.client._call(self.sender, self.request) 58 self.remaining -= 1
59 self.request.offset += self.stride
60 return result.bytes
176 loop=self.loop)
177
178 async def _create_sender(self) -> MTProtoSender:
179 dc = await self.client._get_dc(self.dc_id)180 sender = MTProtoSender(self.auth_key, loggers=self.client._log)
181 await sender.connect(self.client._connection(dc.ip_address, dc.port, dc.id,
182 loggers=self.client._log,
Accessing a protected member (a member prefixed with _
) of a class from outside that class is not recommended, since the creator of that class did not intend this member to be exposed. If accesing this attribute outside of the class is absolutely needed, refactor it such that it becomes part of the public interface of the class.
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
r = Rectangle(4, 8)
area = r._height * r._width
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
def area():
return self._height * self._width
r = Rectangle(4, 8)
area = r.area()