How to use the pipupgrade.log 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 / helper.py View on Github external
# imports - standard imports
import os.path as osp
import json

# imports - module imports
from pipupgrade       import _pip, log
from pipupgrade.model import Registry

logger = log.get_logger()

def get_registry_from_requirements(requirements, sync = False, verbose = False):
    if not verbose:
        logger.setLevel(log.NOTSET)

    path = osp.realpath(requirements)

    # if not osp.exists(path):
    #     cli.echo(cli_format("{} not found.".format(path), cli.RED))
    #     sys.exit(os.EX_NOINPUT)

    packages =  _pip.parse_requirements(requirements, session = "hack")
    registry = Registry(source = path, packages = packages, sync = sync)

    logger.info("Packages within requirements %s found: %s..." % (requirements, registry.packages))
github achillesrasquinha / pipupgrade / src / pipupgrade / helper.py View on Github external
def get_registry_from_requirements(requirements, sync = False, verbose = False):
    if not verbose:
        logger.setLevel(log.NOTSET)

    path = osp.realpath(requirements)

    # if not osp.exists(path):
    #     cli.echo(cli_format("{} not found.".format(path), cli.RED))
    #     sys.exit(os.EX_NOINPUT)

    packages =  _pip.parse_requirements(requirements, session = "hack")
    registry = Registry(source = path, packages = packages, sync = sync)

    logger.info("Packages within requirements %s found: %s..." % (requirements, registry.packages))

    return registry
github achillesrasquinha / pipupgrade / src / pipupgrade / db.py View on Github external
# imports - standard imports
import os.path as osp
import sqlite3

# imports - module imports
from pipupgrade.__attr__    import __name__ as NAME
from pipupgrade.util.string import strip
from pipupgrade.util.system import makedirs, read
from pipupgrade             import config, log

logger = log.get_logger()

IntegrityError      = sqlite3.IntegrityError
OperationalError    = sqlite3.OperationalError

def _get_queries(buffer):
    queries = [ ]
    lines   = buffer.split(";")

    for line in lines:
        line = strip(line)
        queries.append(line)

    return queries

class DB(object):
    def __init__(self, path, timeout = 10):
github achillesrasquinha / pipupgrade / src / pipupgrade / _pip.py View on Github external
# imports - compatibility imports
from pipupgrade._compat import iteritems

# imports - standard imports
import pip
import json
import os.path as osp

# imports - module imports
from pipupgrade.util.system  import which, popen
from pipupgrade.util.string  import kebab_case
from pipupgrade.util.environ import value_to_envval
from pipupgrade.util.array   import sequencify
from pipupgrade              import log

logger = log.get_logger()

PIP9 = int(pip.__version__.split(".")[0]) < 10

if PIP9:
    # from pip                 import get_installed_distributions
    from pip.req             import parse_requirements
    from pip.req.req_install import InstallRequirement
else:
    # from pip._internal.utils.misc      import get_installed_distributions
    from pip._internal.req             import parse_requirements
    from pip._internal.req.req_install import InstallRequirement

from pip._vendor.pkg_resources import (
    Distribution,
    DistInfoDistribution,
    EggInfoDistribution
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
import json

# imports - module imports
from pipupgrade.model         	import Registry
from pipupgrade.commands.util 	import cli_format
from pipupgrade.table      	  	import Table
from pipupgrade.tree			import Node as TreeNode
from pipupgrade.util.string     import pluralize, strip
from pipupgrade.util.system   	import read, write, popen, which
from pipupgrade.util.array		import squash
from pipupgrade 		      	import (_pip, cli, semver,
	log, parallel
)
from pipupgrade.exception		import PopenError

logger = log.get_logger()

_SEMVER_COLOR_MAP 	= dict(
	major = cli.RED,
	minor = cli.YELLOW,
	patch = cli.GREEN
)
_DEPENDENCY_FORMATS = ("tree", "json", "yaml")

def _cli_format_semver(version, type_):
	def _format(x):
		return cli_format(x, cli.YELLOW)
	
	try:
		semver.parse(version)
		
		if type_ == "major":
github achillesrasquinha / pipupgrade / src / pipupgrade / model / package.py View on Github external
# imports - standard imports
from   	datetime	import datetime, timedelta
from 	functools 	import partial
import 	os.path as osp
import 	re

# imports - module imports
from pipupgrade.__attr__    import __name__ as NAME
from pipupgrade 	 		import _pip, semver, request as req, db, log
from pipupgrade.tree 		import Node as TreeNode
from pipupgrade.util.string import kebab_case, strip
from pipupgrade._compat		import iteritems
from pipupgrade.config		import Settings

logger  	= log.get_logger()
_db			= db.get_connection()
settings	= Settings()

def _get_pypi_info(name, raise_err = True):
	url  = "https://pypi.org/pypi/{}/json".format(name)
	res  = req.get(url)

	info = None

	if res.ok:
		data = res.json()
		info = data["info"]
	else:
		if raise_err:
			res.raise_for_status()
github achillesrasquinha / pipupgrade / src / pipupgrade / model / project.py View on Github external
# imports - standard imports
import os, os.path as osp
import fnmatch
import glob

# imports - module imports
from pipupgrade import log
from pipupgrade.util.string import strip

logger = log.get_logger()

class Project(object):
	@staticmethod
	def from_path(path, *args, **kwargs):
		project = Project(path, *args, **kwargs)
		return project

	def __init__(self, path, depth_search = False):
		path = osp.realpath(path)

		if not osp.exists(path):
			logger.error("Failed to initialize project for path %s." % path)
			raise ValueError("Path %s does not exist." % path)
		
		logger.info("Initializing project with path %s." % path)
		self.path         = path
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
)
from pipupgrade.model           import Project
from pipupgrade.model.project 	import get_included_requirements
from pipupgrade.commands.util 	import cli_format
from pipupgrade.util.array    	import flatten, sequencify
from pipupgrade.util.system   	import (read, write, touch, popen, which)
from pipupgrade.util.environ  	import getenvvar
from pipupgrade.util.datetime 	import get_timestamp_str
from pipupgrade 		      	import (_pip, request as req, cli,
	log, parallel
)
from pipupgrade._compat			import builtins
from pipupgrade.__attr__      	import __name__
from pipupgrade.config			import environment

logger = log.get_logger(level = log.DEBUG)

@cli.command
def command(
	packages					= [ ],
	ignore						= [ ],
	pip_path          		 	= [ ],
	requirements 				= [ ],
	pipfile            			= [ ],
	project      				= None,
	pull_request 				= False,
	git_username 				= None,
	git_email    				= None,
	github_access_token			= None,
	github_reponame   		 	= None,
	github_username   			= None,
	target_branch    			= "master",
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
self 		 				= False,
	jobs						= 1,
	user		 				= False,
	check		 				= False,
	interactive  				= False,
	yes			 				= False,
	no_included_requirements 	= False,
	no_cache		            = False,
	no_color 	 				= True,
	output						= None,
	ignore_error				= False,
	force						= False,
	verbose		 				= False
):
	if not verbose:
		logger.setLevel(log.NOTSET)
		
	logger.info("Environment: %s" % environment())
	logger.info("Arguments Passed: %s" % locals())

	file_ = output

	if file_:
		logger.info("Writing to output file %s..." % file_)
		touch(file_)

	cli.echo(cli_format("Checking...", cli.YELLOW), file = file_)

	pip_path    = pip_path or [ ]
	pip_path    = [which(p) for p in pip_path] or _pip._PIP_EXECUTABLES

	logger.info("`pip` executables found: %s" % pip_path)