my eye

Add signature upload

Committed 30e423

--- a/webint_code/__init__.py
+++ b/webint_code/__init__.py

         # return app.view.project.release(project, release, files)
 
 
-def split_release(release):
+def split_release(release) -> tuple:
     """Return a 4-tuple of the parts in given `release` (eg foo-1.2.3 -> foo,1,2,3)."""
-    return re.match(r"([\w.-]+)\-(\d+\.\d+\.\d+.*)", release).groups()
+    if match := re.match(r"([\w.-]+)\-(\d+\.\d+\.\d+.*)", release):
+        return match.groups()
+    return ()
 
 
 @app.control("pypi")
         release_file = release_file.replace(
             releases_dir / f"{release_name}-{release_remaining}"
         )
-        if release_file.suffix == ".gz":
-            subprocess.run(
-                [
-                    "tar",
-                    "xf",
-                    release_file.name,
-                ],
-                cwd=releases_dir,
-            )
-        app.model.create_package(form)
-        # web.application("webint_posts").model.create(
-        #     "entry",
-        #     url=f"/code/{form.name}/releases/{release_file.name}",
-        #     content=(
-        #         f"Released <a href=/code/{form.name}><code>{form.name}</code></a> "
-        #         f"version <code>{release_remaining}</code>"
-        #     ),
-        # )
+        if release_file.suffix == ".asc":
+            message = "Signature has been uploaded."
+            suffix = ".asc"
+        else:
+            message = "Package has been uploaded."
+            suffix = ""
+            if release_file.suffix == ".gz":
+                subprocess.run(
+                    [
+                        "tar",
+                        "xf",
+                        release_file.name,
+                    ],
+                    cwd=releases_dir,
+                )
+                web.application("webint_posts").model.create(
+                    "entry",
+                    url=f"/code/{project['name']}/releases/{release_file.name}",
+                    content=(
+                        f"Released <a href=/code/{project['name']}><code>"
+                        f"{project['name']}</code></a> version "
+                        f"<code>{release_remaining}</code>"
+                    ),
+                )
+            app.model.create_package(form)
         raise web.Created(
-            "Package has been uploaded.",
-            "/{form.name}/packages/{form.content.fileobj.filename}",
+            message,
+            f"/{project['name']}/packages/{form.content.fileobj.filename}{suffix}",
         )
 
 

--- a/webint_code/templates/pypi/project.html
+++ b/webint_code/templates/pypi/project.html

 
 $for package in packages:
     <a href="/projects/$package['name']/releases/$package['filename']\
-    #sha256=$package['sha256_digest']">$package['filename']</a><br>
+    #sha256=$package['sha256_digest']" data-gpg-sig=true>$package['filename']</a><br>