def command(): parser = get_parser() args = parser.parse_args() packages = _pip.get_installed_distributions() npackages = len(packages) query = "Do you wish to update {} packages?".format(npackages) if args.yes or cli.confirm(query): for i, package in enumerate(packages): name = package.project_name info = cli.format( "Updating {} of {} packages: {}".format( i + 1, npackages, name if args.no_color else cli.format(name, cli.GREEN)), cli.BOLD) cli.echo(info) params = list_filter([ "install", "--quiet" if not args.verbose else None, "--no-cache", "--upgrade", name ], filter_=bool) _pip.main(params) cli.echo(cli.format("UPGRADED ALL THE PACKAGES!", cli.BOLD)) return 0
def cli_format(string, type_): args = get_args(as_dict=False) if hasattr(args, "no_color") and not args.no_color: string = cli.format(string, type_) return string
def cli_format(string, type_): args = get_args(as_dict = False) if not args.no_color: string = cli.format(string, type_) return string
def test_format(): string = "foobar" cli.format(string, cli.GREEN) == "{}{}{}".format(cli.GREEN, string, cli.CLEAR)
def _assert_format(string, type_): assert cli.format(string, type_) == "{}{}{}".format(type_, string, cli.CLEAR)
def test__sanitize_string(): assert _sanitize_string(cli.format("foobar", cli.GREEN)) == "foobar" assert _sanitize_string(cli.format("foobar", cli.BOLD)) == "foobar"
def test_strip_ansi(): assert strip_ansi(cli.format("foobar", cli.GREEN)) == "foobar" assert strip_ansi(cli.format("barfoo", cli.BOLD)) == "barfoo"