コード例 #1
0
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        bar = '{bar}'
        spinner = next(SPINNER)
        if self.undefined:
            numerator = self.str_numerator
            template = self.template.format(numerator=numerator,
                                            bar=bar,
                                            spinner=spinner)
        else:
            percent = int(self.percent)
            fraction = self.str_fraction
            eta = self._eta_string or '--:--'
            template = self.template.format(percent=percent,
                                            fraction=fraction,
                                            bar=bar,
                                            eta=eta,
                                            spinner=spinner)

        # Determine bar width and finish.
        width = get_remaining_width(template.format(bar=''), self.max_width
                                    or None)
        bar = self.bar.bar(width, percent=self.percent)
        return template.format(bar=bar)
コード例 #2
0
    def __str__(self):
        """Returns the fully-built progress bar and other data.
        This has been basically copied from the parent class as I have found no elegant solution to append additional
        data to the template using format() otherwise.
        """
        # Partially build out template.
        bar = '{bar}'
        spinner = next(SPINNER)
        if self.undefined:
            numerator = self.str_numerator
            template = self.template.format(numerator=numerator,
                                            bar=bar,
                                            spinner=spinner,
                                            zero=self.zero_faces,
                                            multiple=self.multiple_faces)
        else:
            percent = int(self.percent)
            fraction = self.str_fraction
            eta = self._eta_string or '--:--'
            template = self.template.format(percent=percent,
                                            fraction=fraction,
                                            bar=bar,
                                            eta=eta,
                                            spinner=spinner,
                                            zero=self.zero_faces,
                                            multiple=self.multiple_faces)

        # Determine bar width and finish.
        width = get_remaining_width(template.format(bar=''), self.max_width
                                    or None)
        bar = self.bar.bar(width, percent=self.percent)
        return template.format(bar=bar)
コード例 #3
0
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        filename = '{filename}'
        numerator = self.str_numerator
        eta = self.str_eta
        if self.done:
            template = self.template_completed.format(filename=filename,
                                                      numerator=numerator,
                                                      eta=eta)
        else:
            bar = '{bar}'
            percent = '' if self.undefined else '{0}%'.format(int(
                self.percent))
            rate = self.str_rate
            template = self.template.format(filename=filename,
                                            percent=percent,
                                            bar=bar,
                                            rate=rate,
                                            numerator=numerator,
                                            eta=eta)
        width = get_remaining_width(template.format(bar='', filename=''),
                                    self.max_width or None)

        # Filename will have 40% of the available width if not done.
        if self.done:
            filename = self.filename[:width].ljust(width) if width > 0 else ''
            bar = None
        else:
            width_filename = int(width * 0.4)
            filename = self.filename[:width_filename].ljust(
                width_filename) if width_filename > 0 else ''
            bar = self.bar.bar(width - width_filename, percent=self.percent)
        return template.format(bar=bar, filename=filename)
コード例 #4
0
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        bar = '{bar}'
        numerator = locale.format('%d', self.numerator, grouping=True)
        rate = self.str_rate
        eta = self.str_eta
        if self.undefined:
            template = self.template.format(bar=bar,
                                            numerator=numerator,
                                            rate=rate,
                                            eta=eta)
        else:
            percent = '{0}%'.format(int(self.percent))
            template = self.template.format(percent=percent,
                                            bar=bar,
                                            numerator=numerator,
                                            rate=rate,
                                            eta=eta)

        # Determine bar width and finish.
        width = get_remaining_width(template.format(bar=''), self.max_width
                                    or None)
        bar = self.bar.bar(width, percent=self.percent)
        return template.format(bar=bar)
コード例 #5
0
ファイル: progress.py プロジェクト: Robpol86/etaprogress
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        filename = '{filename}'
        numerator = self.str_numerator
        eta = self.str_eta
        if self.done:
            template = self.template_completed.format(filename=filename, numerator=numerator, eta=eta)
        else:
            bar = '{bar}'
            percent = '' if self.undefined else '{0}%'.format(int(self.percent))
            rate = self.str_rate
            template = self.template.format(filename=filename, percent=percent, bar=bar, rate=rate, numerator=numerator,
                                            eta=eta)
        width = get_remaining_width(template.format(bar='', filename=''), self.max_width or None)

        # Filename will have 40% of the available width if not done.
        if self.done:
            filename = self.filename[:width].ljust(width) if width > 0 else ''
            bar = None
        else:
            width_filename = int(width * 0.4)
            filename = self.filename[:width_filename].ljust(width_filename) if width_filename > 0 else ''
            bar = self.bar.bar(width - width_filename, percent=self.percent)
        return template.format(bar=bar, filename=filename)
コード例 #6
0
ファイル: progress.py プロジェクト: Robpol86/etaprogress
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        bar = '{bar}'
        numerator = locale.format('%d', self.numerator, grouping=True)
        rate = self.str_rate
        eta = self.str_eta
        if self.undefined:
            template = self.template.format(bar=bar, numerator=numerator, rate=rate, eta=eta)
        else:
            percent = '{0}%'.format(int(self.percent))
            template = self.template.format(percent=percent, bar=bar, numerator=numerator, rate=rate, eta=eta)

        # Determine bar width and finish.
        width = get_remaining_width(template.format(bar=''), self.max_width or None)
        bar = self.bar.bar(width, percent=self.percent)
        return template.format(bar=bar)
コード例 #7
0
ファイル: progress.py プロジェクト: Robpol86/etaprogress
    def __str__(self):
        """Returns the fully-built progress bar and other data."""
        # Partially build out template.
        bar = '{bar}'
        spinner = next(SPINNER)
        if self.undefined:
            numerator = self.str_numerator
            template = self.template.format(numerator=numerator, bar=bar, spinner=spinner)
        else:
            percent = int(self.percent)
            fraction = self.str_fraction
            eta = self._eta_string or '--:--'
            template = self.template.format(percent=percent, fraction=fraction, bar=bar, eta=eta, spinner=spinner)

        # Determine bar width and finish.
        width = get_remaining_width(template.format(bar=''), self.max_width or None)
        bar = self.bar.bar(width, percent=self.percent)
        return template.format(bar=bar)