Skip to content

Commit

Permalink
slight tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Apr 4, 2022
1 parent bb69e6d commit bdf32a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tqdm/contrib/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Usage:
>>> from tqdm.contrib.discord import tqdm, trange
>>> for i in tqdm(iterable, token='{token}', channel_id='{channel_id}'):
>>> for i in trange(10, token='{token}', channel_id='{channel_id}'):
... ...
![screenshot](https://img.tqdm.ml/screenshot-discord.png)
Expand Down
15 changes: 7 additions & 8 deletions tqdm/contrib/slack.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""
Sends updates to a Slack app.
Usage:
>>> from tqdm.contrib.slack import tqdm, trange
>>> for i in tqdm(iterable, token='{token}', channel='{channel}'):
>>> for i in trange(10, token='{token}', channel='{channel}'):
... ...
![screenshot](https://img.tqdm.ml/screenshot-slack.png)
"""
from __future__ import absolute_import
Expand Down Expand Up @@ -33,8 +35,7 @@ def __init__(self, token, channel):
self.channel = channel
self.text = self.__class__.__name__
try:
self.message = self.client.chat_postMessage(
channel=channel, text=self.text)
self.message = self.client.chat_postMessage(channel=channel, text=self.text)
except Exception as e:
tqdm_auto.write(str(e))

Expand All @@ -47,11 +48,8 @@ def write(self, s):
return # skip duplicate message
self.text = s
try:
future = self.submit(
self.client.chat_update,
channel=self.message["channel"],
ts=self.message["ts"],
text='`' + s + '`')
future = self.submit(self.client.chat_update, channel=self.message["channel"],
ts=self.message["ts"], text='`' + s + '`')
except Exception as e:
tqdm_auto.write(str(e))
else:
Expand Down Expand Up @@ -80,6 +78,7 @@ def __init__(self, *args, **kwargs):
[default: ${TQDM_SLACK_CHANNEL}].
mininterval : float, optional.
Minimum of [default: 1.5] to avoid rate limit.
See `tqdm.auto.tqdm.__init__` for other parameters.
"""
if not kwargs.get('disable'):
Expand Down

0 comments on commit bdf32a7

Please sign in to comment.