aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-08-07 01:01:10 +0100
committerSam James <sam@gentoo.org>2023-08-07 01:04:33 +0100
commit1c6189be723e5048737f45cf531e35ec8725b727 (patch)
tree243b1532e8a6aad3d3f150569136df1ffa25ee59
parentRun `pyupgrade` (diff)
downloadmirrorselect-1c6189be723e5048737f45cf531e35ec8725b727.tar.gz
mirrorselect-1c6189be723e5048737f45cf531e35ec8725b727.tar.bz2
mirrorselect-1c6189be723e5048737f45cf531e35ec8725b727.zip
Drop Python 2 support
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--mirrorselect/mirrorparser3.py15
-rw-r--r--mirrorselect/selectors.py27
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 <sebastian@pipping.org>
Copyright (C) 2009 Christian Ruppert <idl0r@gentoo.org>
@@ -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