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

Fix pdm show specific package with werid output #580

Merged
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 news/580.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix pdm show weird package info.
14 changes: 9 additions & 5 deletions pdm/models/project_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def __init__(self, metadata: Distribution | Metadata) -> None:

def _parse(self, data: Distribution) -> dict[str, Any]:
metadata = data.metadata
keywords = metadata.get("Keywords", "").replace(",", ", ")
platform = metadata.get("Platform", "").replace(",", ", ")
project_urls = {
k.strip(): v.strip()
for k, v in (row.split(",") for row in metadata.get_all("Project-URL", []))
}
return {
"name": metadata["Name"],
"version": metadata["Version"],
Expand All @@ -32,12 +38,10 @@ def _parse(self, data: Distribution) -> dict[str, Any]:
"email": metadata.get("Author-email", ""),
"license": metadata.get("License", ""),
"requires-python": metadata.get("Requires-Python", ""),
"platform": ", ".join(metadata.get("Platform", [])),
"keywords": ", ".join(metadata.get("Keywords", [])),
"platform": platform,
"keywords": keywords,
"homepage": metadata.get("Home-page", ""),
"project-urls": [
": ".join(parts) for parts in metadata.get("Project-URL", [])
],
"project-urls": [": ".join(parts) for parts in project_urls.items()],
}

def _parse_self(self, metadata: Metadata) -> dict[str, Any]:
Expand Down