How to use the pipupgrade.cli.echo function in pipupgrade

To help you get started, we’ve selected a few pipupgrade 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 achillesrasquinha / pipupgrade / tests / pipupgrade / cli / test_cli_util.py View on Github external
def test_echo(capfd):
    query  = "foobar"
    cli.echo(query, nl = False)
    assert_stdout(capfd, query)
    
    cli.echo(query, nl = True)
    assert_stdout(capfd, "{}\n".format(query))
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
def update_pip(pip_exec, user = None, quiet = None, file = None):
	cli.echo(cli_format("Updating %s..." % pip_exec, cli.YELLOW),
		file = file)

	output = pip_upgrade("pip", pip_exec = pip_exec, user = user, quiet = quiet)

	if isinstance(output, int):
		code = output
	else:
		code = output[0]

	if not code:
		cli.echo("%s upto date." % cli_format(pip_exec, cli.CYAN),
			file = file)

	return output
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
body  = body
					)
					
					# Although there's monkey patch support for the "requests"
					# library, avoid using the "json" parameter which was
					# added in requests 2.4.2+
					response  = req.post(url, data = json.dumps(data), headers = headers)

					if response.ok:
						response = response.json()
						number   = response["number"]

						url      = "/".join(map(str, ["https://github.com", github_username, github_reponame, "pull", number]))
						message  = "Created a Pull Request at %s" % url

						cli.echo(cli_format(message, cli.GREEN), file = file_)
					else:
						response.raise_for_status()
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
dinfo  = nodes

		if 	 format_ == "tree":
			string = _render_dependency_tree(nodes)
		elif format_ == "json":
			string = _render_json(nodes)
		elif format_ == "yaml":
			string = _render_yaml(nodes)
		elif format_ == "table":
			string = table.render()
	
		cli.echo("\nSource: %s\n" % stitle, file = file)
		
		if not interactive or check:
			cli.echo(string, file = file)
			cli.echo(file = file)

		if not check:
			packages  = [p for p in dinfo if p.difference in upgrade_type
				or p.difference == "major"]
			packages  = [p for p in dinfo if p.difference != "major" 
				or getattr(p, "has_dependency_conflict", False) or latest]

			npackages = len(packages)

			spackages = pluralize("package", npackages) # Packages "string"
			query     = "Do you wish to update %s %s?" % (npackages, spackages)

			if npackages and (yes or interactive or cli.confirm(query, quit_ = True)):
				for i, package in enumerate(packages):
					update = True
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / outdated.py View on Github external
#             if diff_type == "patch":
    #                 project_name = cli_format(project_name, cli.GREEN)
                
    #             version_latest = _cli_format_semver(version_latest, type_ = diff_type)

    table    = Table(header = ["Package", "Current", "Latest", "Home Page"])
    for package in packages:
        table.insert([
            package.name,
            package.current_version,
            package.latest_version,
            package.home_page
        ])

    string = cli_format("All packages are upto date.", cli.GREEN) if table.empty else table.render()
    cli.echo(string)
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
nodes  = _resolve_dependencies(nodes)
			dinfo  = nodes

		if 	 format_ == "tree":
			string = _render_dependency_tree(nodes)
		elif format_ == "json":
			string = _render_json(nodes)
		elif format_ == "yaml":
			string = _render_yaml(nodes)
		elif format_ == "table":
			string = table.render()
	
		cli.echo("\nSource: %s\n" % stitle, file = file)
		
		if not interactive or check:
			cli.echo(string, file = file)
			cli.echo(file = file)

		if not check:
			packages  = [p for p in dinfo if p.difference in upgrade_type
				or p.difference == "major"]
			packages  = [p for p in dinfo if p.difference != "major" 
				or getattr(p, "has_dependency_conflict", False) or latest]

			npackages = len(packages)

			spackages = pluralize("package", npackages) # Packages "string"
			query     = "Do you wish to update %s %s?" % (npackages, spackages)

			if npackages and (yes or interactive or cli.confirm(query, quit_ = True)):
				for i, package in enumerate(packages):
					update = True
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / outdated.py View on Github external
def command():
    cli.echo("Checking...")

    packages = get_packages_info(raise_err = False)
    # if diff_type == "major":
    #                 project_name = cli_format(project_name, cli.RED)
    #             if diff_type == "minor":
    #                 project_name = cli_format(project_name, cli.YELLOW)
    #             if diff_type == "patch":
    #                 project_name = cli_format(project_name, cli.GREEN)
                
    #             version_latest = _cli_format_semver(version_latest, type_ = diff_type)

    table    = Table(header = ["Package", "Current", "Latest", "Home Page"])
    for package in packages:
        table.insert([
            package.name,
            package.current_version,
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
def update_pip(pip_exec, user = None, quiet = None, file = None):
	cli.echo(cli_format("Updating %s..." % pip_exec, cli.YELLOW),
		file = file)

	output = pip_upgrade("pip", pip_exec = pip_exec, user = user, quiet = quiet)

	if isinstance(output, int):
		code = output
	else:
		code = output[0]

	if not code:
		cli.echo("%s upto date." % cli_format(pip_exec, cli.CYAN),
			file = file)

	return output
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
if render:
		if format_ in _DEPENDENCY_FORMATS:
			nodes  = _resolve_dependencies(nodes)
			dinfo  = nodes

		if 	 format_ == "tree":
			string = _render_dependency_tree(nodes)
		elif format_ == "json":
			string = _render_json(nodes)
		elif format_ == "yaml":
			string = _render_yaml(nodes)
		elif format_ == "table":
			string = table.render()
	
		cli.echo("\nSource: %s\n" % stitle, file = file)
		
		if not interactive or check:
			cli.echo(string, file = file)
			cli.echo(file = file)

		if not check:
			packages  = [p for p in dinfo if p.difference in upgrade_type
				or p.difference == "major"]
			packages  = [p for p in dinfo if p.difference != "major" 
				or getattr(p, "has_dependency_conflict", False) or latest]

			npackages = len(packages)

			spackages = pluralize("package", npackages) # Packages "string"
			query     = "Do you wish to update %s %s?" % (npackages, spackages)