mirror of https://github.com/tqdm/tqdm.git
telegram: `delete()` on `leave=False`
- also misc minor tidy
This commit is contained in:
parent
f1071d7d03
commit
c36a011c3a
|
@ -63,17 +63,15 @@ class TelegramIO(MonoWorker):
|
||||||
return future
|
return future
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
|
"""Deletes internal `message_id`."""
|
||||||
try:
|
try:
|
||||||
res = self.submit(
|
future = self.submit(
|
||||||
self.session.post,
|
self.session.post, self.API + '%s/deleteMessage' % self.token,
|
||||||
self.API + '%s/deleteMessage' % self.token,
|
data={'chat_id': self.chat_id, 'message_id': self.message_id})
|
||||||
data=dict(
|
|
||||||
chat_id=self.chat_id,
|
|
||||||
message_id=self.message_id))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
tqdm_auto.write(str(e))
|
tqdm_auto.write(str(e))
|
||||||
else:
|
else:
|
||||||
return res
|
return future
|
||||||
|
|
||||||
|
|
||||||
class tqdm_telegram(tqdm_auto):
|
class tqdm_telegram(tqdm_auto):
|
||||||
|
@ -125,8 +123,12 @@ class tqdm_telegram(tqdm_auto):
|
||||||
if not self.disable:
|
if not self.disable:
|
||||||
self.tgio.write("")
|
self.tgio.write("")
|
||||||
|
|
||||||
def delete(self):
|
def close(self):
|
||||||
self.tgio.delete()
|
if self.disable:
|
||||||
|
return
|
||||||
|
super(tqdm_telegram, self).close()
|
||||||
|
if not (self.leave or (self.leave is None and self.pos == 0)):
|
||||||
|
self.tgio.delete()
|
||||||
|
|
||||||
|
|
||||||
def ttgrange(*args, **kwargs):
|
def ttgrange(*args, **kwargs):
|
||||||
|
|
|
@ -113,10 +113,10 @@ class tqdm_rich(std_tqdm): # pragma: no cover
|
||||||
self._prog.__enter__()
|
self._prog.__enter__()
|
||||||
self._task_id = self._prog.add_task(self.desc or "", **d)
|
self._task_id = self._prog.add_task(self.desc or "", **d)
|
||||||
|
|
||||||
def close(self, *args, **kwargs):
|
def close(self):
|
||||||
if self.disable:
|
if self.disable:
|
||||||
return
|
return
|
||||||
super(tqdm_rich, self).close(*args, **kwargs)
|
super(tqdm_rich, self).close()
|
||||||
self._prog.__exit__(None, None, None)
|
self._prog.__exit__(None, None, None)
|
||||||
|
|
||||||
def clear(self, *_, **__):
|
def clear(self, *_, **__):
|
||||||
|
|
Loading…
Reference in New Issue