]> git.scottworley.com Git - pinch/blobdiff - pinch.py
Rename top-level procedures
[pinch] / pinch.py
index dfdedac03258749d0f9a539cf533537abcba54a6..f0f0422047a0f434b9c07c618a9ac5dea45f84ea 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -36,6 +36,7 @@ class Info(types.SimpleNamespace):
     channel_html: bytes
     forwarded_url: str
     git_revision: str
+    release_name: str
     table: Dict[str, InfoTableEntry]
     url: str
 
@@ -119,14 +120,23 @@ def fetch(v: Verification, channel_url: str) -> Info:
     return info
 
 
-def parse_table(v: Verification, info: Info) -> None:
+def parse_channel(v: Verification, info: Info) -> None:
     v.status('Parsing channel description as XML')
     d = xml.dom.minidom.parseString(info.channel_html)
     v.ok()
 
-    v.status('Extracting git commit')
+    v.status('Extracting release name:')
+    title_name = d.getElementsByTagName(
+        'title')[0].firstChild.nodeValue.split()[2]
+    h1_name = d.getElementsByTagName('h1')[0].firstChild.nodeValue.split()[2]
+    v.status(title_name)
+    v.result(title_name == h1_name)
+    info.release_name = title_name
+
+    v.status('Extracting git commit:')
     git_commit_node = d.getElementsByTagName('tt')[0]
     info.git_commit = git_commit_node.firstChild.nodeValue
+    v.status(info.git_commit)
     v.ok()
     v.status('Verifying git commit label')
     v.result(git_commit_node.previousSibling.nodeValue == 'Git commit ')
@@ -196,9 +206,9 @@ def fetch_resources(v: Verification, info: Info) -> None:
             info.table['git-revision'].file).read(999) == info.git_commit)
 
 
-def extract_channel(v: Verification, info: Info) -> None:
+def check_channel_contents(v: Verification, info: Info) -> None:
     with tempfile.TemporaryDirectory() as d:
-        v.status('Extracting nixexprs.tar.xz')
+        v.status('Extracting %s' % info.table['nixexprs.tar.xz'].file)
         shutil.unpack_archive(info.table['nixexprs.tar.xz'].file, d)
         v.ok()
         v.status('Removing temporary directory')
@@ -208,9 +218,9 @@ def extract_channel(v: Verification, info: Info) -> None:
 def main() -> None:
     v = Verification()
     info = fetch(v, 'https://channels.nixos.org/nixos-20.03')
-    parse_table(v, info)
+    parse_channel(v, info)
     fetch_resources(v, info)
-    extract_channel(v, info)
+    check_channel_contents(v, info)
     print(info)