Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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
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()
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
# 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)
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
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,
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
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)