Skip to main content
`Ctrl`+`K`

# vispy.util.fetching module

Data downloading and reading functions

class vispy.util.fetching.ProgressBar(max_value, initial_value=0, mesg='', max_chars=40, progress_character='.', spinner=False)

  Bases: `object`

  Class for generating a command-line progressbar

  Parameters:
    max_value int

      Maximum value of process (e.g. number of samples to process, bytes to download, etc.).

    initial_value int

      Initial value of process, useful when resuming process from a specific value, defaults to 0.

    mesg str

      Message to include at end of progress bar.

    max_chars int

      Number of characters to use for progress bar (be sure to save some room for the message and % complete as well).

    progress_character char

      Character in the progress bar that indicates the portion completed.

    spinner bool

      Show a spinner. Useful for long-running processes that may not increment the progress bar very often. This provides the user with feedback that the progress has not stalled.

  spinner_symbols = ['|', '/', '-', '\\']
  template = '\r[{0}{1}] {2:.05f} {3} {4} '
  update(cur_value, mesg=None)

    Update progressbar with current value of process

    Parameters:
      cur_value number

        Current value of process. Should be <= max_value (but this is not enforced). The percent of the progressbar will be computed as (cur_value / max_value) * 100

      mesg str

        Message to display to the right of the progressbar. If None, the last message provided will be used. To clear the current message, pass a null string, ‘’.

  update_with_increment_value(increment_value, mesg=None)

    Update progressbar with the value of the increment instead of the current value of process as in update()

    Parameters:
      increment_value int

        Value of the increment of process. The percent of the progressbar will be computed as (self.cur_value + increment_value / max_value) * 100

      mesg str

        Message to display to the right of the progressbar. If None, the last message provided will be used. To clear the current message, pass a null string, ‘’.

vispy.util.fetching.load_data_file(fname, directory=None, force_download=False)

  Get a standard vispy demo data file

  Parameters:
    fname str

      The filename on the remote `demo-data` repository to download, e.g. `'molecular_viewer/micelle.npy'`. These correspond to paths on `https://github.com/vispy/demo-data/`.

    directory str | None

      Directory to use to save the file. By default, the vispy configuration directory is used.

    force_download bool | str

      If True, the file will be downloaded even if a local copy exists (and this copy will be overwritten). Can also be a YYYY-MM-DD date to ensure a file is up-to-date (modified date of a file on disk, if present, is checked).

  Returns:
    fname str

      The path to the file on the local system.

vispy.util.fetching.sizeof_fmt(num)

  Turn number of bytes into human-readable str