From ca2c3eddd11811b0c494763e3d99614e9f6c62e7 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 8 Apr 2020 17:48:32 -0700 Subject: [PATCH 1/1] main creates the Channel --- pinch.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pinch.py b/pinch.py index 89e053b..a8b6103 100644 --- 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) -- 2.44.1