SPPAS 4.22

https://sppas.org/

Module sppas.config

Class sppasBaseProgress

Description

Base class for a progress bar to be used while processing some task.

Constructor

Create a sppasBaseProgress instance.

View Source
def __init__(self, *args, **kwargs):
    """Create a sppasBaseProgress instance."""
    self._percent = 0
    self._text = ''
    self._header = ''

Public functions

update

Update the progress.

Parameters
  • message: (str) progress bar value (default: 0)
  • percent: (float) progress bar text (default: None)
View Source
def update(self, percent=None, message=None):
    """Update the progress.

        :param message: (str) progress bar value (default: 0)
        :param percent: (float) progress bar text  (default: None)

        """
    if percent is not None:
        self._percent = percent
    if message is not None:
        logging.info('  => ' + message)
        self._text = message

clear

Clear.

View Source
def clear(self):
    """Clear."""
    pass

set_fraction

Set a new progress value.

Parameters
  • percent: (float) new progress value
View Source
def set_fraction(self, percent):
    """Set a new progress value.

        :param percent: (float) new progress value

        """
    self.update(percent=percent)

set_text

Set a new progress message text.

Parameters
  • text: (str) new progress text
View Source
def set_text(self, text):
    """Set a new progress message text.

        :param text: (str) new progress text

        """
    self.update(message=text.strip())

set_header

Set a new progress header text.

Parameters
  • header: (str) new progress header text.
View Source
def set_header(self, header):
    """Set a new progress header text.

        :param header: (str) new progress header text.

        """
    if len(header) > 0:
        self._header = '          * * *  ' + header + '  * * *  '
    else:
        self._header = ''
    logging.info(self._header)

set_new

Initialize a new progress line.

View Source
def set_new(self):
    """Initialize a new progress line."""
    self.set_header('')
    self.update(percent=0, message='')

close

View Source
def close(self):
    pass