How to use the pipupgrade.commands.util.cli_format 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 / src / pipupgrade / commands / helper.py View on Github external
def get_registry_from_requirements(requirements, sync = False, jobs = 1,
	only_packages = [ ], file = None, ignore_packages = [ ]):
	path = osp.realpath(requirements)

	if not osp.exists(path):
		cli.echo(cli_format("{} not found.".format(path), cli.RED),
			file = file)
		sys.exit(os.EX_NOINPUT)
	else:
		packages =  _pip.parse_requirements(requirements, session = "hack")
		
		if only_packages:
			packages = [p for p in packages if p.name in only_packages]

		if ignore_packages:
			packages = [p for p in packages if p["name"] not in ignore_packages]

		registry = Registry(source = path, packages = packages, sync = sync,
			jobs = jobs
		)

	logger.info("Packages within requirements %s found: %s..." % (
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
logger.info("Updating Pipfiles: %s..." % pipfile)

			cli.echo(cli_format("Updating Pipfiles: %s..." % ", ".join(pipfile), cli.YELLOW),
				file = file_)

			with parallel.no_daemon_pool(processes = jobs) as pool:
				results = pool.imap_unordered(
					partial(
						update_pipfile,
						**{ "verbose": verbose }
					),
					pipfile
				)

				if builtins.all(results):
					cli.echo(cli_format("Pipfiles upto date.", cli.GREEN),
						file = file_)

		if project and pull_request:
			errstr = '%s not found. Use %s or the environment variable "%s" to set value.'

			if not git_username:
				raise ValueError(errstr % ("Git Username", "--git-username", getenvvar("GIT_USERNAME")))
			if not git_email:
				raise ValueError(errstr % ("Git Email",    "--git-email",    getenvvar("GIT_EMAIL")))
			
			for p in project:
				popen("git config user.name  %s" % git_username, cwd = p.path)
				popen("git config user.email %s" % git_email,    cwd = p.path)

				_, output, _ = popen("git status -s", output = True,
					cwd = p.path)
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
current_version		= package.current_version
		
		if all or current_version:
			current_version = current_version.replace("==", "")

		if all or (package.latest_version and current_version != package.latest_version):
			render	  = True

			if format_ in _DEPENDENCY_FORMATS:
				nodes.append(package)
			else:
				table.insert([
					cli_format(package.name, _SEMVER_COLOR_MAP.get(package.difference, cli.CLEAR)),
					package.current_version or "na",
					_cli_format_semver(package.latest_version, package.difference),
					cli_format(package.home_page, cli.CYAN)
				])

			dinfo.append(package)

	stitle = "Installed Distributions (%s)" % source if registry.installed else source
	
	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":
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
, cli.BOLD), file = file)

						if not package.installed:
							_update_requirements(package.source, package)
						else:
							try:
								_pip.call("install", package.name,
									pip_exec = package.source, user = user,
									quiet = not verbose, no_cache_dir = True,
									upgrade = True
								)
							except PopenError as e:
								if raise_err:
									raise
	else:
		cli.echo("%s upto date." % cli_format(stitle, cli.CYAN),
			file = file)
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
"file": file_ }
				),
				pip_path
			)

	if self:
		package = __name__
		logger.info("Updating %s..." % package)

		cli.echo(cli_format("Updating %s..." % package, cli.YELLOW),
			file = file_)

		_pip.call("install", package, user = user, quiet = not verbose,
			no_cache = True, upgrade = True)

		cli.echo("%s upto date." % cli_format(package, cli.CYAN),
			file = file_)
	else:
		if project:
			project		 = sequencify(project)
			requirements = requirements or [ ]
			pipfile      = pipfile      or [ ]

			logger.info("Detecting projects and its dependencies...")
			
			with parallel.no_daemon_pool(processes = jobs) as pool:
				project       = pool.imap_unordered(
					partial(
						Project.from_path,
						**{ "depth_search": force }
					),
					project