Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: try to fix show issue #52

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vpip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def install_global(packages, upgrade=False, latest=False):
with vv.activate(True):
# TODO: make pip support install_scripts
# https://github.com/pypa/pip/issues/3934
print(f"\nInstalling {pkg}")
pip_api.install([pkg], upgrade=upgrade, latest=latest)
link_console_script(spec_to_pkg(pkg))
except Exception:
Expand Down
23 changes: 12 additions & 11 deletions vpip/pip_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,32 +98,33 @@ def show(packages, verbose=False):
if verbose:
cmd += " --verbose"

result = []
ns = Namespace()
result = [Namespace()]
last_name = None

for line in execute_pip("{} {}".format(cmd, " ".join(packages)), True):
if line.startswith("---"):
result.append(ns)
ns = Namespace()
result.append(Namespace())
last_name = None
continue

match = re.match(r"([\w-]+):\s*(.*)", line)
# header name
match = re.match(r"([\x21-\x7e]+):(.*)", line)
if match:
name, value = match.groups()
name = case_conversion.snakecase(name)
value = value.strip()
setattr(ns, name, value)
value = value.rstrip("\r\n")
value = value.lstrip()
setattr(result[-1], name, value)
last_name = name
continue

match = re.match(r"\s+(\S.*)", line)
# header value folded
match = re.match(r"(\s+\S.*)", line)
if match and last_name:
value = getattr(ns, last_name) + "\n" + match.group(1).strip()
setattr(ns, last_name, value)
value = getattr(result[-1], last_name) + match.group(1).rstrip("\r\n")
setattr(result[-1], last_name, value)
continue

result.append(ns)
return result

def list_(not_required=False, format="json"):
Expand Down
Loading