From: Scott Worley Date: Thu, 9 Apr 2020 00:48:32 +0000 (-0700) Subject: main creates the Channel X-Git-Tag: 1.0~19 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/ca2c3eddd11811b0c494763e3d99614e9f6c62e7?ds=sidebyside;hp=72d3478ad2577fcb6a8d2ffdaff2beb8e8579dd7 main creates the Channel --- 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)