From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 455EE15800A for ; Mon, 7 Aug 2023 00:14:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 861D12BC018; Mon, 7 Aug 2023 00:14:22 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6F2F42BC018 for ; Mon, 7 Aug 2023 00:14:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7D077340CD7 for ; Mon, 7 Aug 2023 00:14:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C0BA8F21 for ; Mon, 7 Aug 2023 00:14:19 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1691366673.1c6189be723e5048737f45cf531e35ec8725b727.sam@gentoo> Subject: [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/ X-VCS-Repository: proj/mirrorselect X-VCS-Files: mirrorselect/mirrorparser3.py mirrorselect/selectors.py X-VCS-Directories: mirrorselect/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 1c6189be723e5048737f45cf531e35ec8725b727 X-VCS-Branch: master Date: Mon, 7 Aug 2023 00:14:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 32eb297c-9902-42ba-a928-f5015a646c10 X-Archives-Hash: 4fa0e83380febb1f8c9b43f4bb199e76 commit: 1c6189be723e5048737f45cf531e35ec8725b727 Author: Sam James gentoo org> AuthorDate: Mon Aug 7 00:01:10 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Aug 7 00:04:33 2023 +0000 URL: https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=1c6189be Drop Python 2 support Signed-off-by: Sam James gentoo.org> mirrorselect/mirrorparser3.py | 15 +++++---------- mirrorselect/selectors.py | 27 +++++++-------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/mirrorselect/mirrorparser3.py b/mirrorselect/mirrorparser3.py index f89c61e..133420a 100644 --- a/mirrorselect/mirrorparser3.py +++ b/mirrorselect/mirrorparser3.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Mirrorselect 2.x Tool for selecting Gentoo source and rsync mirrors. -Copyright 2009-2012 Gentoo Foundation +Copyright 2009-2023 Gentoo Authors Copyright (C) 2009 Sebastian Pipping Copyright (C) 2009 Christian Ruppert @@ -81,14 +81,9 @@ class MirrorParser3: if __name__ == '__main__': import sys - if sys.version_info[0] >= 3: - import urllib.request, urllib.parse, urllib.error - parser = MirrorParser3() - parser.parse(urllib.request.urlopen(MIRRORS_3_XML).read()) - else: - import urllib - parser = MirrorParser3() - parser.parse(urllib.urlopen(MIRRORS_3_XML).read()) + import urllib.request, urllib.parse, urllib.error + parser = MirrorParser3() + parser.parse(urllib.request.urlopen(MIRRORS_3_XML).read()) print('===== tuples') print(parser.tuples()) print('===== uris') diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py index a17a646..df66cc4 100644 --- a/mirrorselect/selectors.py +++ b/mirrorselect/selectors.py @@ -37,26 +37,13 @@ import sys import time import hashlib -if sys.version_info[0] >= 3: - import urllib.request, urllib.parse, urllib.error - url_parse = urllib.parse.urlparse - url_unparse = urllib.parse.urlunparse - url_open = urllib.request.urlopen - url_request = urllib.request.Request - HTTPError = urllib.error.HTTPError - import http.client - IncompleteRead = http.client.IncompleteRead -else: - import urllib2 - import urlparse - url_parse = urlparse.urlparse - url_unparse = urlparse.urlunparse - url_open = urllib2.urlopen - url_request = urllib2.Request - HTTPError = urllib2.HTTPError - import httplib - IncompleteRead = httplib.IncompleteRead - +import urllib.request, urllib.parse, urllib.error +url_parse = urllib.parse.urlparse +url_unparse = urllib.parse.urlunparse +url_open = urllib.request.urlopen +url_request = urllib.request.Request +HTTPError = urllib.error.HTTPError +import http.client from mirrorselect.output import encoder, get_encoding, decode_selection