Skip to content

Commit

Permalink
Merge pull request #115 from wimglenn/project-url-homepage
Browse files Browse the repository at this point in the history
parse homepage from new project_urls metadata field
  • Loading branch information
wimglenn authored Jan 26, 2023
2 parents 63e5d29 + 7f6f92a commit 5e0dd4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion johnnydep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Display dependency tree of Python distribution"""

__version__ = "1.17.4"
__version__ = "1.17.5"

from johnnydep.lib import *
4 changes: 4 additions & 0 deletions johnnydep/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def children(self):

@property
def homepage(self):
for project_url in self.metadata.get("project_urls", []):
if project_url.lower().startswith("homepage, "):
_, url = project_url.split(", ", 1)
return url
try:
return self.metadata["home_page"]
except KeyError:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def test_homepage(make_dist):
assert jdist.homepage == "https://www.example.org/default"


def test_homepage_from_project_urls(make_dist):
make_dist(project_url=["url1, https://blah", "homepage, https://www.example.org/proj_url"])
jdist = JohnnyDist("jdtest")
assert jdist.homepage == "https://www.example.org/proj_url"


def test_no_homepage(make_dist):
make_dist(url=None)
jdist = JohnnyDist("jdtest")
Expand Down

0 comments on commit 5e0dd4b

Please sign in to comment.