Skip to content

Commit

Permalink
cli --update/--update_to auto-float (default int)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Sep 12, 2020
1 parent c0d9c61 commit 1f22123
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tqdm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from .std import tqdm, TqdmTypeError, TqdmKeyError
from ._version import __version__ # NOQA
from ast import literal_eval as numeric
import logging
import re
import sys
Expand Down Expand Up @@ -301,10 +302,10 @@ def write(x):
with tqdm(**tqdm_args) as t:
if update:
def callback(i):
t.update(float(i))
t.update(numeric(i))
else: # update_to
def callback(i):
t.update(float(i) - t.n)
t.update(numeric(i) - t.n)
for i in stdin:
stdout.write(i)
callback(i)
Expand All @@ -317,10 +318,10 @@ def callback(i):
callback_len = False
if update:
def callback(i):
t.update(float(i))
t.update(numeric(i))
elif update_to:
def callback(i):
t.update(float(i) - t.n)
t.update(numeric(i) - t.n)
else:
callback = t.update
callback_len = True
Expand Down

0 comments on commit 1f22123

Please sign in to comment.