How to use the rich.progress.BarColumn function in rich

To help you get started, we’ve selected a few rich examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AcidWeb / CurseBreaker / CurseBreaker.py View on Github external
def c_uninstall(self, args):
        if args:
            if args.startswith('-k '):
                args = args[3:]
                optkeep = True
            else:
                optkeep = False
            addons = self.parse_args(args)
            with Progress('{task.completed}/{task.total}', '|', BarColumn(bar_width=None), '|',
                          auto_refresh=False, console=self.console) as progress:
                task = progress.add_task('', total=len(addons))
                while not progress.finished:
                    for addon in addons:
                        name, version = self.core.del_addon(addon, optkeep)
                        if name:
                            self.table.add_row(f'[bold red]Uninstalled[/bold red]',
                                               Text(name, no_wrap=True), Text(version, no_wrap=True))
                        else:
                            self.table.add_row(f'[bold black]Not installed[/bold black]',
                                               Text(addon, no_wrap=True), Text('', no_wrap=True))
                        progress.update(task, advance=1, refresh=True)
            self.console.print(self.table)
        else:
            self.console.print('[green]Usage:[/green]\n\tThis command accepts a space-separated list of addon names or '
                               'full links as an argument.\n\t[bold white]Flags:[/bold white]\n\t\t[bold white]-k[/bold'
github AcidWeb / CurseBreaker / CurseBreaker.py View on Github external
def c_install(self, args):
        if args:
            if args.startswith('-i '):
                args = args[3:]
                optignore = True
            else:
                optignore = False
            args = re.sub(r'(\w)([ ]+)(\w)', r'\1,\3', args)
            addons = [addon.strip() for addon in list(reader([args], skipinitialspace=True))[0]]
            with Progress('{task.completed}/{task.total}', '|', BarColumn(bar_width=None), '|',
                          auto_refresh=False, console=self.console) as progress:
                task = progress.add_task('', total=len(addons))
                while not progress.finished:
                    for addon in addons:
                        installed, name, version = self.core.add_addon(addon, optignore)
                        if installed:
                            self.table.add_row('[green]Installed[/green]', Text(name, no_wrap=True),
                                               Text(version, no_wrap=True))
                        else:
                            self.table.add_row('[bold black]Already installed[/bold black]',
                                               Text(name, no_wrap=True), Text(version, no_wrap=True))
                        progress.update(task, advance=1, refresh=True)
            self.console.print(self.table)
        else:
            self.console.print('[green]Usage:[/green]\n\tThis command accepts a space-separated list of links as an arg'
                               'ument.[bold white]\n\tFlags:[/bold white]\n\t\t[bold white]-i[/bold white] - Disable th'
github AcidWeb / CurseBreaker / CurseBreaker.py View on Github external
def c_update(self, args, addline=False, update=True, force=False, provider=False):
        if len(self.core.cfCache) > 0 or len(self.core.wowiCache) > 0:
            self.core.cfCache = {}
            self.core.wowiCache = {}
            self.core.checksumCache = {}
        if args:
            addons = self.parse_args(args)
            compacted = -1
        else:
            addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
            compacted = 0
        exceptions = []
        with Progress('{task.completed:.0f}/{task.total}', '|', BarColumn(bar_width=None), '|',
                      auto_refresh=False, console=None if self.headless else self.console) as progress:
            task = progress.add_task('', total=len(addons))
            if not args:
                self.core.bulk_check(addons)
                self.core.bulk_check_checksum(addons, progress)
            while not progress.finished:
                for addon in addons:
                    try:
                        # noinspection PyTypeChecker
                        name, versionnew, versionold, modified, blocked, source = self.core.\
                            update_addon(addon if isinstance(addon, str) else addon['URL'], update, force)
                        if provider:
                            source = f' [bold white]{source}[/bold white]'
                        else:
                            source = ''
                        if versionold:
github AcidWeb / CurseBreaker / CB / Core.py View on Github external
def backup_wtf(self, console):
        zipf = zipfile.ZipFile(Path('WTF-Backup', f'{datetime.datetime.now().strftime("%d%m%y")}.zip'), 'w',
                               zipfile.ZIP_DEFLATED)
        filecount = 0
        for _, _, files in os.walk('WTF/', topdown=True):
            files = [f for f in files if not f[0] == '.']
            filecount += len(files)
        with Progress('{task.completed}/{task.total}', '|', BarColumn(bar_width=None), '|', auto_refresh=False,
                      console=console) as progress:
            task = progress.add_task('', total=filecount)
            while not progress.finished:
                for root, _, files in os.walk('WTF/', topdown=True):
                    files = [f for f in files if not f[0] == '.']
                    for f in files:
                        zipf.write(Path(root, f))
                        progress.update(task, advance=1, refresh=True)
        zipf.close()
github efenka / mtv_dl / mtv_dl.py View on Github external
def progress_bar() -> Iterator[Progress]:
    progress_console = console
    if HIDE_PROGRESSBAR:
        progress_console = Console(file=open(os.devnull, 'w'))
    with Progress(TextColumn("[bold blue]{task.description}", justify="right"),
                  BarColumn(bar_width=None),
                  "[progress.percentage]{task.percentage:>3.1f}%",
                  TimeRemainingColumn(),
                  refresh_per_second=4,
                  console=progress_console) as progress:
        yield progress