How to use the pipupgrade._compat.iteritems 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__init__.py View on Github external
def foobar(*args, **kwargs):
            args    = get_args()
            params  = merge_dict(args, override)
            
            for k, v in iteritems(values):
                assert params[k] == v

            if initial:
                for k in iterkeys(initial):
                    assert initial[k] == args[k]
github achillesrasquinha / pipupgrade / tests / pipupgrade / test__compat.py View on Github external
def test_iteritems():
    dict_ = dict(foo = "bar")
    
    assert isinstance(iteritems(dict_), Iterable)

    for k, v in iteritems(dict_):
        assert dict_[k] == v
github achillesrasquinha / pipupgrade / tests / pipupgrade / test__compat.py View on Github external
def test_iteritems():
    dict_ = dict(foo = "bar")
    
    assert isinstance(iteritems(dict_), Iterable)

    for k, v in iteritems(dict_):
        assert dict_[k] == v
github achillesrasquinha / pipupgrade / src / pipupgrade / model / registry.py View on Github external
def _build_packages_info_dict(packages, pip_exec = None):
    details         = _get_pip_info(*packages, pip_exec = pip_exec)

    requirements    = [ ]

    for name, detail in iteritems(details):
        if not name in _INFO_DICT:
            _INFO_DICT[name] = dict({
                     "version": detail["version"], 
                "dependencies": compact(detail["requires"].split(", "))
            })

            for requirement in _INFO_DICT[name]["dependencies"]:
                if requirement not in requirements:
                    requirements.append(requirement)

    if requirements:
        _build_packages_info_dict(requirements, pip_exec = pip_exec)
github achillesrasquinha / pipupgrade / src / pipupgrade / config.py View on Github external
def _init(self):
        for k, v in iteritems(Settings._DEFAULTS):
            self.set(k, v)
github achillesrasquinha / pipupgrade / src / pipupgrade / model / package.py View on Github external
def _get_pip_info(*args, **kwargs):
	packages	= args
	pip_exec	= kwargs.get("pip_exec", None)
	
	_, out, _	= _pip.call("show", *packages, pip_exec = pip_exec,
		output = True)
	results		= [strip(o) for o in out.split("---")]
	
	info		= dict()
	
	for i, package in enumerate(packages):
		result = results[i]

		detail = dict((kebab_case(k), v) \
			for k, v in \
				iteritems(
					dict([(s + [""]) if len(s) == 1 else s \
						for s in [re.split(r":\s?", o, maxsplit = 1) \
							for o in result.split("\n")]]
					)
				)
		)

		info[package] = detail
	
	return info
github achillesrasquinha / pipupgrade / src / pipupgrade / util / types.py View on Github external
if _compat.PY2:
        argspec_getter = inspect.getargspec
        success        = True
    if _compat.PYTHON_VERSION >= (3,0) and _compat.PYTHON_VERSION < (3,5):
        argspec_getter = inspect.getfullargspec
        success        = True

    if success:
        argspec   = argspec_getter(fn)
        params    = dict_from_list(argspec.args, argspec.defaults or [])

    if _compat.PYTHON_VERSION >= (3,5):
        signature  = inspect.signature(fn)
        parameters = signature.parameters

        params     = { k: v.default for k, v in _compat.iteritems(parameters) }

        success    = True

    if not success:
        raise ValueError("Unknown Python Version {} for fetching functional arguments.".format(sys.version))

    return params
github achillesrasquinha / pipupgrade / src / pipupgrade / util / system.py View on Github external
def popen(*args, **kwargs):
    output      = kwargs.get("output", False)
    quiet       = kwargs.get("quiet" , False)
    directory   = kwargs.get("cwd")
    environment = kwargs.get("env")
    shell       = kwargs.get("shell", True)
    raise_err   = kwargs.get("raise_err", True)

    environ     = os.environ.copy()
    if environment:
        environ.update(environment)

    for k, v in iteritems(environ):
        environ[k] = str(v)

    command     = " ".join([str(arg) for arg in args])

    logger.info("Executing command: %s" % command)

    if quiet:
        output  = True
    
    proc        = sp.Popen(command,
        bufsize = -1,
        stdin   = sp.PIPE if output else None,
        stdout  = sp.PIPE if output else None,
        stderr  = sp.PIPE if output else None,
        env     = environ,
        cwd     = directory,