Voice et bot modif

This commit is contained in:
pi 2026-06-16 17:09:34 +00:00
parent 189d56026b
commit 7333a22bcd
10774 changed files with 634644 additions and 933308 deletions

View file

@ -9,7 +9,6 @@ Usage:
![screenshot](https://tqdm.github.io/img/screenshot-slack.png)
"""
import logging
from os import getenv
try:
from slack_sdk import WebClient
@ -17,6 +16,7 @@ except ImportError:
raise ImportError("Please `pip install slack-sdk`")
from ..auto import tqdm as tqdm_auto
from ..utils import envwrap
from .utils_worker import MonoWorker
__author__ = {"github.com/": ["0x2b3bfa0", "casperdcl"]}
@ -56,7 +56,7 @@ class SlackIO(MonoWorker):
return future
class tqdm_slack(tqdm_auto):
class tqdm_slack(tqdm_auto): # pylint: disable=inconsistent-mro
"""
Standard `tqdm.auto.tqdm` but also sends updates to a Slack app.
May take a few seconds to create (`__init__`).
@ -68,7 +68,8 @@ class tqdm_slack(tqdm_auto):
>>> for i in tqdm(iterable, token='{token}', channel='{channel}'):
... ...
"""
def __init__(self, *args, **kwargs):
@envwrap("tqdm", "slack", is_method=True)
def __init__(self, *args, token=None, channel=None, **kwargs):
"""
Parameters
----------
@ -84,19 +85,17 @@ class tqdm_slack(tqdm_auto):
if not kwargs.get('disable'):
kwargs = kwargs.copy()
logging.getLogger("HTTPClient").setLevel(logging.WARNING)
self.sio = SlackIO(
kwargs.pop('token', getenv("TQDM_SLACK_TOKEN")),
kwargs.pop('channel', getenv("TQDM_SLACK_CHANNEL")))
self.sio = SlackIO(token, channel)
kwargs['mininterval'] = max(1.5, kwargs.get('mininterval', 1.5))
super().__init__(*args, **kwargs)
def display(self, **kwargs):
def display(self, **kwargs): # pylint: disable=arguments-differ
super().display(**kwargs)
fmt = self.format_dict
if fmt.get('bar_format', None):
fmt['bar_format'] = fmt['bar_format'].replace(
'<bar/>', '`{bar:10}`').replace('{bar}', '`{bar:10u}`')
else:
elif self.total:
fmt['bar_format'] = '{l_bar}`{bar:10}`{r_bar}'
if fmt['ascii'] is False:
fmt['ascii'] = [":black_square:", ":small_blue_diamond:", ":large_blue_diamond:",