def test_kebab_case(): assert kebab_case("foo bar") == "foo-bar" assert kebab_case("Foo Bar") == "foo-bar" assert kebab_case("FOO BAR") == "foo-bar" assert kebab_case("_FOO_BAR_", delimiter="_") == "foo-bar" assert kebab_case("foo_bar", delimiter="_") == "foo-bar"
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
def call(*args, **kwargs): pip_exec = kwargs.pop("pip_exec", _PIP_EXECUTABLE) params = sequencify(pip_exec) + sequencify(args) for flag, value in iteritems(kwargs): if value != False: flag = "--%s" % kebab_case(flag, delimiter = "_") params.append(flag) if not isinstance(value, bool): value = value_to_envval(value) params.append(value) return popen(*params, output = True)
def call(*args, **kwargs): pip_exec = kwargs.pop("pip_exec", None) or _PIP_EXECUTABLE quiet = kwargs.pop("quiet", None) or False output = kwargs.pop("output", None) or False raise_err = kwargs.pop("raise_err", None) or True params = sequencify(pip_exec) + sequencify(args) for flag, value in iteritems(kwargs): if value != False: flag = "--%s" % kebab_case(flag, delimiter="_") params.append(flag) if not isinstance(value, bool): value = value_to_envval(value) params.append(value) output = output or quiet output = popen(*params, output=output, raise_err=raise_err) return output