Remove old python2 code from cache

This commit is contained in:
Stephan Kulow 2019-11-05 11:14:54 +01:00
parent de4ff14a71
commit a595666eef

View File

@ -1,5 +1,3 @@
from __future__ import print_function
import datetime import datetime
import hashlib import hashlib
import os import os
@ -7,18 +5,9 @@ import osc.core
import re import re
import sys import sys
try: from urllib.parse import unquote
from urllib.parse import unquote from urllib.parse import urlsplit, SplitResult
from urllib.parse import urlsplit, SplitResult from urllib.error import URLError, HTTPError
from urllib.error import URLError, HTTPError
from io import StringIO
except ImportError:
# python 2.x
from urlparse import urlsplit, SplitResult
from urllib import unquote
from urllib2 import URLError, HTTPError
from StringIO import StringIO
from io import BytesIO from io import BytesIO
from osc import conf from osc import conf
@ -27,12 +16,7 @@ from osclib.cache_manager import CacheManager
from osclib.conf import str2bool from osclib.conf import str2bool
from osclib.util import rmtree_nfs_safe from osclib.util import rmtree_nfs_safe
from time import time from time import time
from xml.etree import cElementTree as ET
try:
from xml.etree import cElementTree as ET
except ImportError:
import cElementTree as ET
def http_request(method, url, headers={}, data=None, file=None): def http_request(method, url, headers={}, data=None, file=None):
""" """
@ -209,7 +193,7 @@ class Cache(object):
# Since urlopen does not return a seekable stream it cannot be reset # Since urlopen does not return a seekable stream it cannot be reset
# after writing to cache. As such a wrapper must be used. This could # after writing to cache. As such a wrapper must be used. This could
# be replaced with urlopen('file://...') to be consistent, but until # be replaced with urlopen('file://...') to be consistent, but until
# the need arrises StringIO has less overhead. # the need arrises BytesIO has less overhead.
text = data.read() text = data.read()
data = BytesIO(text) data = BytesIO(text)