Skip to content

Progress viewer

ProgressViewer

View class for the Backup Juggler application.

Attributes:

Name Type Description
_pbar Any

The progress bar instance.

Methods
  • _update: Update the progress bar with the given chunk size.
Notes
  • The progress bar is created using the tqdm library.
  • The progress bar updates are performed in the _update method.
Source code in backup_juggler/progress_viewer.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class ProgressViewer:
    """
    View class for the Backup Juggler application.

    Attributes:
        _pbar: The progress bar instance.

    Methods:
        - _update: Update the progress bar with the given chunk size.

    Notes:
        - The progress bar is created using the `tqdm` library.
        - The progress bar updates are performed in the `_update` method.
    """

    def __init__(self, paths: Paths) -> None:
        """
        Initialize a `ProgressViewer` instance.

        Args:
            paths: The `Paths` instance.
        """

        self._pbar: Any = tqdm(
            total=paths.total_size,
            unit='B',
            unit_scale=True,
            desc=f'Copying {paths.source.name} to {paths.destination.name}',
        )

    def _update(self, chunk_size: int) -> None:
        """
        Update the progress bar with the given chunk size.

        Args:
            chunk_size: The size of the chunk to update the progress.
        """

        self._pbar.update(chunk_size)

__init__(paths)

Initialize a ProgressViewer instance.

Parameters:

Name Type Description Default
paths Paths

The Paths instance.

required
Source code in backup_juggler/progress_viewer.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, paths: Paths) -> None:
    """
    Initialize a `ProgressViewer` instance.

    Args:
        paths: The `Paths` instance.
    """

    self._pbar: Any = tqdm(
        total=paths.total_size,
        unit='B',
        unit_scale=True,
        desc=f'Copying {paths.source.name} to {paths.destination.name}',
    )