def __init__(self, maxval=None, widgets=None, term_width=None, poll=0.1,
                 left_justify=True, fd=sys.stderr, redirect_stderr=False,
                 redirect_stdout=False):
        '''Initializes a progress bar with sane defaults'''

        if widgets is None:
            # Don't share widgets with any other progress bars
            widgets = self.default_widgets()

        self.maxval = maxval
        self.widgets = widgets
        self.fd = fd
        self.left_justify = left_justify
        self.redirect_stderr = redirect_stderr
        self.redirect_stdout = redirect_stdout

        self.signal_set = False
        if term_width is not None:
            self.term_width = term_width
        else:
            try:
                self._handle_resize()
                signal.signal(signal.SIGWINCH, self._handle_resize)
                self.signal_set = True
            except (SystemExit, KeyboardInterrupt):  # pragma: no cover
                raise
            except:  # pragma: no cover
                self.term_width = self._env_size()

        self.__iterable = None
        self._update_widgets()
        self.currval = 0
        self.finished = False
        self.last_update_time = None
        self.poll = poll
        self.seconds_elapsed = 0
        self.start_time = None
        self.update_interval = 1
def __init__ ( self , maxval = None , widgets = None , term_width = None , poll = 0.1 , left_justify = True , fd = sys . stderr , redirect_stderr = False , redirect_stdout = False ) : if widgets is None : widgets = self . default_widgets ( ) self . maxval = maxval self . widgets = widgets self . fd = fd self . left_justify = left_justify self . redirect_stderr = redirect_stderr self . redirect_stdout = redirect_stdout self . signal_set = False if term_width is not None : self . term_width = term_width else : try : self . _handle_resize ( ) signal . signal ( signal . SIGWINCH , self . _handle_resize ) self . signal_set = True except ( SystemExit , KeyboardInterrupt ) : raise except : self . term_width = self . _env_size ( ) self . __iterable = None self . _update_widgets ( ) self . currval = 0 self . finished = False self . last_update_time = None self . poll = poll self . seconds_elapsed = 0 self . start_time = None self . update_interval = 1
Initializes a progress bar with sane defaults