public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/
Date: Fri, 24 Mar 2023 13:56:32 +0000 (UTC)	[thread overview]
Message-ID: <1679666166.5704c77f5cabed06be363df78ca03b6e66566a97.arthurzam@gentoo> (raw)

commit:     5704c77f5cabed06be363df78ca03b6e66566a97
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 21 16:09:02 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Mar 24 13:56:06 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=5704c77f

python: Rewrite "one PyPI URL" check to reuse PYPI_SDIST_URI_RE

Technically this is less optimal than the original code but it opens up
the possibility of enabling PYPI_PN support next.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/python.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 19b87ef5..95295271 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -815,18 +815,17 @@ class PythonFetchableCheck(Check):
         if len(pypi_uris) == 1:
             uri, filename = pypi_uris[0]
 
-            def matches_fn(expected_fn: str) -> bool:
-                expected = f"{PYPI_URI_PREFIX}source/{pkg.package[0]}/{pkg.package}/{expected_fn}"
-                return uri == expected and filename == expected_fn
-
-            version = self.translate_version(pkg.version)
-            append = len(uris) > 1
-            if matches_fn(f"{self.normalize_distribution_name(pkg.package)}-{version}.tar.gz"):
-                yield PythonInlinePyPIURI(uri, normalize=True, append=append, pkg=pkg)
-                return
-            if matches_fn(f"{pkg.package}-{version}.tar.gz"):
-                yield PythonInlinePyPIURI(uri, normalize=False, append=append, pkg=pkg)
-                return
+            if source_match := PYPI_SDIST_URI_RE.match(uri):
+                pn, filename_pn, pv, suffix = source_match.groups()
+                if pv == self.translate_version(pkg.version) and suffix == ".tar.gz":
+                    append = len(uris) > 1
+                    normalize = filename_pn == self.normalize_distribution_name(pn)
+                    if not normalize and filename_pn != pn:
+                        # ignore malformed URLs
+                        return
+                    if pn == pkg.package:
+                        yield PythonInlinePyPIURI(uri, normalize=normalize, append=append, pkg=pkg)
+                        return
 
         # otherwise, yield result for every URL, with suggested replacement
         for uri, dist_filename in pypi_uris:


             reply	other threads:[~2023-03-24 13:56 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 13:56 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-06 16:28 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/ Arthur Zamarin
2024-07-04 20:06 Arthur Zamarin
2024-05-09 19:39 Arthur Zamarin
2024-05-08 16:32 Arthur Zamarin
2024-03-01 21:06 Arthur Zamarin
2023-12-10 20:07 Arthur Zamarin
2023-12-08 18:38 Arthur Zamarin
2023-12-08 17:52 Arthur Zamarin
2023-11-05 13:22 Arthur Zamarin
2023-11-01 19:20 Arthur Zamarin
2023-09-14 17:02 Arthur Zamarin
2023-09-14 17:02 Arthur Zamarin
2023-09-01 16:42 Arthur Zamarin
2023-08-29 18:58 Arthur Zamarin
2023-08-03 17:28 Arthur Zamarin
2023-08-02 11:59 Arthur Zamarin
2023-07-15 10:17 Arthur Zamarin
2023-06-24  7:52 Arthur Zamarin
2023-05-12 17:21 Arthur Zamarin
2023-03-18 15:04 Arthur Zamarin
2023-03-11  7:18 Arthur Zamarin
2023-03-04 18:24 Arthur Zamarin
2023-02-18 18:33 Arthur Zamarin
2023-02-17 10:10 Arthur Zamarin
2023-02-16 18:44 Arthur Zamarin
2023-02-05 17:56 Arthur Zamarin
2023-02-05 17:18 Arthur Zamarin
2023-01-31 17:08 Arthur Zamarin
2023-01-31 16:44 Arthur Zamarin
2023-01-24 18:57 Arthur Zamarin
2023-01-20 15:01 Arthur Zamarin
2023-01-20 15:01 Arthur Zamarin
2023-01-20 13:20 Arthur Zamarin
2023-01-14 20:31 Arthur Zamarin
2022-12-27 19:15 Arthur Zamarin
2022-12-13 19:59 Arthur Zamarin
2022-10-29 18:46 Arthur Zamarin
2022-10-29  5:43 Arthur Zamarin
2022-10-12 18:06 Arthur Zamarin
2022-10-07 12:42 Arthur Zamarin
2022-10-05 16:46 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1679666166.5704c77f5cabed06be363df78ca03b6e66566a97.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox