How to use the pipupgrade.util.string.strip 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 / util / test_string.py View on Github external
def test_strip():
    string = "foobar"
    assert strip(string) == string

    string = "\n   foobar\nfoobar   \n   "
    assert strip(string) == "foobar\nfoobar"

    string = "\n\n\n"
    assert strip(string) == ""
github achillesrasquinha / pipupgrade / tests / pipupgrade / util / test_string.py View on Github external
def test_strip():
    string = "foobar"
    assert strip(string) == string

    string = "\n   foobar\nfoobar   \n   "
    assert strip(string) == "foobar\nfoobar"

    string = "\n\n\n"
    assert strip(string) == ""
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")]]
					)
				)
		)
github achillesrasquinha / pipupgrade / src / pipupgrade / util / system.py View on Github external
code       = proc.wait()

    if code and raise_err:
        raise PopenError(code, command)

    if output:
        output, error = proc.communicate()

        if output:
            output = safe_decode(output)
            output = strip(output)

        if error:
            error  = safe_decode(error)
            error  = strip(error)

        if quiet:
            return code
        else:
            return code, output, error
    else:
        return code
github achillesrasquinha / pipupgrade / src / pipupgrade / util / system.py View on Github external
env     = environ,
        cwd     = directory,
        shell   = shell
    )

    code       = proc.wait()

    if code and raise_err:
        raise PopenError(code, command)

    if output:
        output, error = proc.communicate()

        if output:
            output = safe_decode(output)
            output = strip(output)

        if error:
            error  = safe_decode(error)
            error  = strip(error)

        if quiet:
            return code
        else:
            return code, output, error
    else:
        return code
github achillesrasquinha / pipupgrade / src / pipupgrade / db.py View on Github external
def _get_queries(buffer):
    queries = [ ]
    lines   = buffer.split(";")

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

    return queries
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
def _render_yaml(packages):
	try:
		import yaml

		content = _render_json(packages)
		dict_   = dict()

		for details in content:
			name = details.pop("name")
			dict_[name] = details

		string  = strip(yaml.safe_dump(dict_))

		return string
	except ImportError:
		raise ValueError((
			"Unable to import yaml. "
			"Please install pyyaml. https://github.com/yaml/pyyaml."
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
def _render_dependency_tree(packages):
	rendered = [ ]

	for package in packages:
		dependencies 	= package.dependency_tree
		string			= dependencies.render(indent = 4,
			formatter = lambda package: _format_package(package)
		)

		sanitized		= strip(string)
		
		rendered.append(sanitized)

	string = strip("\n".join(rendered))

	return string