Skip to content

Commit

Permalink
[PyPi] 1.1.1 Fix project URLs
Browse files Browse the repository at this point in the history
Repro previous error using `[p]pypi spike`
  • Loading branch information
Kreusada committed Jun 26, 2023
1 parent 433f5c5 commit b6aea29
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/cog_pypi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Through this guide, ``[p]`` will always represent your prefix. Replace

.. note::

This guide was last updated for version 1.0.11. Ensure
This guide was last updated for version 1.1.1. Ensure
that you are up to date by running ``[p]cog update pypi``.

If there is something missing, or something that needs improving
Expand Down
2 changes: 1 addition & 1 deletion pypi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Through this guide, ``[p]`` will always represent your prefix. Replace

.. note::

This guide was last updated for version 1.0.11. Ensure
This guide was last updated for version 1.1.1. Ensure
that you are up to date by running ``[p]cog update pypi``.

If there is something missing, or something that needs improving
Expand Down
64 changes: 35 additions & 29 deletions pypi/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PyPi(commands.Cog):
"""Get information about a package available on PyPi."""

__author__ = ["Kreusada", "OofChair"]
__version__ = "1.1.0"
__version__ = "1.1.1"

def __init__(self, bot):
self.bot = bot
Expand Down Expand Up @@ -129,33 +129,38 @@ async def pypi(self, ctx, project: str):
name="Installation", value=box(f"pip install -U {info['name']}"), inline=False
)

filtered_links = dict(
filter(lambda x: URL_RE.match(x[1]), list(info["project_urls"].items()))
)
for link in info["project_urls"].values():
match = GIT_REPO_RE.match(link)
if not match or match.group(1) == "sponsors":
continue
try:
details = await self.make_request(
("https://api.github.com/repos/" + link[19:]).rstrip(".git")
)
except ValueError:
default_branch = None
else:
default_branch = details["default_branch"]
break
else:
default_branch = None
project_urls = info["project_urls"]
filtered_links = {}

if default_branch:
embed.add_field(
name="Development Installation",
value=box(
f"pip install -U git+{link}@{default_branch}#egg={info['name']}", lang="fix"
),
inline=False,
if project_urls:

filtered_links = dict(
filter(lambda x: URL_RE.match(x[1]), list(info["project_urls"].items()))
)
for link in info["project_urls"].values():
match = GIT_REPO_RE.match(link)
if not match or match.group(1) == "sponsors":
continue
try:
details = await self.make_request(
("https://api.github.com/repos/" + link[19:]).rstrip(".git")
)
except ValueError:
default_branch = None
else:
default_branch = details["default_branch"]
break
else:
default_branch = None

if default_branch:
embed.add_field(
name="Development Installation",
value=box(
f"pip install -U git+{link}@{default_branch}#egg={info['name']}", lang="fix"
),
inline=False,
)

values = []
for release in list(releases.keys())[-5:]:
Expand All @@ -165,9 +170,10 @@ async def pypi(self, ctx, project: str):
release_time = "-".join(reversed(release_time.split("-"))) # format date properly
values.append(f"+ {release} (~{release_time})")

embed.add_field(
name="Recent Releases", value=box("\n".join(values), lang="diff"), inline=False
)
if values:
embed.add_field(
name="Recent Releases", value=box("\n".join(values), lang="diff"), inline=False
)

if requires_dist := info["requires_dist"]:
value = "\n".join(
Expand Down

0 comments on commit b6aea29

Please sign in to comment.