@@ -1991,17 +1991,44 @@ def __init__(
19911991 except OSError :
19921992 width = 79
19931993
1994+ self .override_limits (stop , start , log )
1995+
19941996 self .major = width // 10
19951997 self .width = 10 * self .major
1998+ self .prefix = prefix
1999+ self .informant = display if informant is True else informant
2000+ self .prev_index = 0
2001+ self .started = False
2002+ self .informer = get_informer ()
2003+
2004+ # prepare for use of markers
2005+ def to_color (c ):
2006+ if c :
2007+ return Color (c ) if is_str (c ) else c
2008+ return lambda c : c
2009+ self .markers = {None : ('⋅' , to_color (None ))}
2010+ self .markers .update ({k :(v [0 ], to_color (v [1 ])) for k ,v in markers .items ()})
2011+ self .prev_marker = None
2012+ self .use_prev_marker = False
2013+ self .previously_shown = ''
2014+
2015+ # override_limits() {{{3
2016+ def override_limits (self , stop , start , log ):
2017+ """
2018+ Overrides start, stop, and log settings
19962019
1997- # process start, stop, log, etc.
2020+ Not normally needed. Generally used to give the limits when they are not
2021+ known in advance. Initiate with bogus limits and use this function to
2022+ override before the first draw operation.
2023+ """
19982024 try :
19992025 self .iterator = stop
20002026 stop = len (stop )
20012027 start = 0
2002- log = False
2028+ assert not log
20032029 except TypeError :
20042030 self .iterator = None
2031+
20052032 if log :
20062033 from math import log10
20072034 start = log10 (start )
@@ -2013,25 +2040,10 @@ def __init__(
20132040 self .start = start
20142041 self .stop = stop
20152042 self .log = log
2016- self .prefix = prefix
2017- self .informant = display if informant is True else informant
2018- self .prev_index = 0
2019- self .started = False
2020- self .finished = not bool (stop - start )
2043+
2044+ self .finished = stop == start
20212045 # if stop == start, just declare progress bar to be done;
20222046 # doing so avoids the divide by zero problem
2023- self .informer = get_informer ()
2024-
2025- # prepare for use of markers
2026- def to_color (c ):
2027- if c :
2028- return Color (c ) if is_str (c ) else c
2029- return lambda c : c
2030- self .markers = {None : ('⋅' , to_color (None ))}
2031- self .markers .update ({k :(v [0 ], to_color (v [1 ])) for k ,v in markers .items ()})
2032- self .prev_marker = None
2033- self .use_prev_marker = False
2034- self .previously_shown = ''
20352047
20362048 # draw() {{{3
20372049 def draw (self , abscissa , marker = None ):
0 commit comments