]> git.scottworley.com Git - pinch/commitdiff
main creates the Channel
authorScott Worley <scottworley@scottworley.com>
Thu, 9 Apr 2020 00:48:32 +0000 (17:48 -0700)
committerScott Worley <scottworley@scottworley.com>
Thu, 9 Apr 2020 00:49:20 +0000 (17:49 -0700)
pinch.py

index 89e053b9bb648244ce8758e8cef4e3373c8708b0..a8b6103c3bb78e157673afadeca0864ff85ce231 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -107,17 +107,13 @@ def compare(a: str,
     return filecmp.cmpfiles(a, b, files, shallow=False)
 
 
-def fetch(v: Verification, channel_url: str) -> Channel:
-    channel = Channel()
-    channel.url = channel_url
+def fetch(v: Verification, channel: Channel) -> None:
     v.status('Fetching channel')
-    request = urllib.request.urlopen(
-        'https://channels.nixos.org/nixos-20.03', timeout=10)
+    request = urllib.request.urlopen(channel.url, timeout=10)
     channel.channel_html = request.read()
     channel.forwarded_url = request.geturl()
     v.result(request.status == 200)
     v.check('Got forwarded', channel.url != channel.forwarded_url)
-    return channel
 
 
 def parse_channel(v: Verification, channel: Channel) -> None:
@@ -217,7 +213,8 @@ def check_channel_contents(v: Verification, channel: Channel) -> None:
 
 def main() -> None:
     v = Verification()
-    channel = fetch(v, 'https://channels.nixos.org/nixos-20.03')
+    channel = Channel(url='https://channels.nixos.org/nixos-20.03')
+    fetch(v, channel)
     parse_channel(v, channel)
     fetch_resources(v, channel)
     check_channel_contents(v, channel)