Add "Raises" section in docstrings

This commit is contained in:
Dan 2017-12-30 19:23:18 +01:00
parent 1df1762d54
commit 8be5351452

View File

@ -111,6 +111,23 @@ class Client:
"""Use this method to manually stop the Client.""" """Use this method to manually stop the Client."""
self.session.stop() self.session.stop()
def signal_handler(self, *args):
self.stop()
self.is_idle.set()
def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
"""Blocks the program execution until one of the signals are received,
then gently stop the Client by closing the underlying connection.
Args:
stop_signals:
Iterable containing signals the signal handler will listen to.
"""
for s in stop_signals:
signal(s, self.signal_handler)
self.is_idle.wait()
# TODO: Better update handler # TODO: Better update handler
def set_update_handler(self, callback: callable): def set_update_handler(self, callback: callable):
"""Use this method to set the update handler """Use this method to set the update handler
@ -131,26 +148,11 @@ class Client:
data: data:
The API Scheme function filled with proper arguments. The API Scheme function filled with proper arguments.
Raises:
:class:`pyrogram.Error`
""" """
return self.session.send(data) return self.session.send(data)
def signal_handler(self, *args):
self.stop()
self.is_idle.set()
def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
"""Blocks the program execution until one of the signals are received,
then gently stop the Client by closing the underlying connection.
Args:
stop_signals:
Iterable containing signals the signal handler will listen to.
"""
for s in stop_signals:
signal(s, self.signal_handler)
self.is_idle.wait()
def authorize(self): def authorize(self):
while True: while True:
phone_number = input("Enter phone number: ") phone_number = input("Enter phone number: ")
@ -431,6 +433,9 @@ class Client:
Returns: Returns:
Full information about the user in form of a **UserFull** object. Full information about the user in form of a **UserFull** object.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.users.GetFullUser( functions.users.GetFullUser(
@ -466,6 +471,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.SendMessage( functions.messages.SendMessage(
@ -503,6 +511,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.ForwardMessages( functions.messages.ForwardMessages(
@ -548,6 +559,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(photo) file = self.save_file(photo)
@ -614,6 +628,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(audio) file = self.save_file(audio)
@ -674,6 +691,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(document) file = self.save_file(document)
@ -741,6 +761,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(video) file = self.save_file(video)
@ -804,6 +827,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(voice) file = self.save_file(voice)
@ -866,6 +892,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
file = self.save_file(video_note) file = self.save_file(video_note)
@ -925,6 +954,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
@ -981,6 +1013,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
@ -1034,6 +1069,9 @@ class Client:
Returns: Returns:
On success, the sent Message is returned. On success, the sent Message is returned.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
@ -1068,6 +1106,8 @@ class Client:
progress: progress:
Progress of the upload process. Progress of the upload process.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.SetTyping( functions.messages.SetTyping(
@ -1093,6 +1133,9 @@ class Client:
limit: limit:
Limits the number of photos to be retrieved. Limits the number of photos to be retrieved.
Values between 1100 are accepted. Defaults to 100. Values between 1100 are accepted. Defaults to 100.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.photos.GetUserPhotos( functions.photos.GetUserPhotos(
@ -1123,6 +1166,9 @@ class Client:
disable_web_page_preview: disable_web_page_preview:
Disables link previews for links in this message. Disables link previews for links in this message.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
@ -1149,6 +1195,9 @@ class Client:
caption: caption:
New caption of the message. New caption of the message.
Raises:
:class:`pyrogram.Error`
""" """
return self.send( return self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
@ -1175,6 +1224,9 @@ class Client:
revoke: revoke:
Deletes messages on both parts (for private chats). Deletes messages on both parts (for private chats).
Raises:
:class:`pyrogram.Error`
""" """
# TODO: Maybe "revoke" is superfluous. # TODO: Maybe "revoke" is superfluous.
# If I want to delete a message, chances are I want it to # If I want to delete a message, chances are I want it to
@ -1392,6 +1444,9 @@ class Client:
chat_id: chat_id:
Unique identifier for the target chat in form of *t.me/joinchat/* links or username of the target Unique identifier for the target chat in form of *t.me/joinchat/* links or username of the target
channel (in the format @channelusername) channel (in the format @channelusername)
Raises:
:class:`pyrogram.Error`
""" """
match = self.INVITE_LINK_RE.match(chat_id) match = self.INVITE_LINK_RE.match(chat_id)
@ -1429,6 +1484,9 @@ class Client:
delete: delete:
Deletes the group chat dialog after leaving (for simple group chats, not supergroups). Deletes the group chat dialog after leaving (for simple group chats, not supergroups).
Raises:
:class:`pyrogram.Error`
""" """
peer = self.resolve_peer(chat_id) peer = self.resolve_peer(chat_id)
@ -1468,6 +1526,9 @@ class Client:
Returns: Returns:
On success, the exported invite link as string is returned. On success, the exported invite link as string is returned.
Raises:
:class:`pyrogram.Error`
""" """
peer = self.resolve_peer(chat_id) peer = self.resolve_peer(chat_id)