py3: Replace urllib imports with six.moves.urllib

The urllib, urllib2 and urlparse modules of Python 2 were reorganized
into a new urllib namespace on Python 3. Replace urllib, urllib2 and
urlparse imports with six.moves.urllib to make the modified code
compatible with Python 2 and Python 3.

The initial patch was generated by the urllib operation of the sixer
tool on: bin/* swift/ test/.

Change-Id: I61a8c7fb7972eabc7da8dad3b3d34bceee5c5d93
This commit is contained in:
Victor Stinner 2015-10-08 15:03:52 +02:00
parent f2cac20d17
commit c0af385173
42 changed files with 96 additions and 79 deletions

View File

@ -16,7 +16,6 @@
import os
import sys
from urllib import quote
from hashlib import md5
import getopt
from itertools import chain
@ -24,6 +23,7 @@ from itertools import chain
import simplejson
from eventlet.greenpool import GreenPool
from eventlet.event import Event
from six.moves.urllib.parse import quote
from swift.common.ring import Ring
from swift.common.utils import split_path

View File

@ -14,9 +14,10 @@ from __future__ import print_function
import itertools
import os
import sqlite3
import urllib
from hashlib import md5
from six.moves import urllib
from swift.common.utils import hash_path, storage_directory, \
Timestamp
from swift.common.ring import Ring
@ -100,7 +101,7 @@ def print_ring_locations(ring, datadir, account, container=None, obj=None,
for node in primary_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part,
urllib.quote(target))
urllib.parse.quote(target))
if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index)
@ -108,7 +109,7 @@ def print_ring_locations(ring, datadir, account, container=None, obj=None,
for node in handoff_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part,
urllib.quote(target))
urllib.parse.quote(target))
if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index)

View File

@ -19,9 +19,9 @@
from __future__ import print_function
from eventlet.green import urllib2
from six.moves.urllib.parse import urlparse
from swift.common.utils import SWIFT_CONF_FILE
from swift.common.ring import Ring
from urlparse import urlparse
from hashlib import md5
import eventlet
import json

View File

@ -28,7 +28,6 @@ BufferedHTTPResponse.
from swift import gettext_ as _
from swift.common import constraints
from urllib import quote
import logging
import time
import socket
@ -36,6 +35,7 @@ import socket
import eventlet
from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \
HTTPResponse, HTTPSConnection, _UNKNOWN
from six.moves.urllib.parse import quote
import six
httplib = eventlet.import_patched('httplib')

View File

@ -15,12 +15,12 @@
import functools
import os
import urllib
import time
from urllib import unquote
import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from six.moves import urllib
from six.moves.urllib.parse import unquote
from swift.common import utils, exceptions
from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \
@ -246,7 +246,7 @@ def check_mount(root, drive):
:param drive: drive name to be checked
:returns: True if it is a valid mounted device, False otherwise
"""
if not (urllib.quote_plus(drive) == drive):
if not (urllib.parse.quote_plus(drive) == drive):
return False
path = os.path.join(root, drive)
return utils.ismount(path)

View File

@ -17,12 +17,12 @@ from eventlet import sleep, Timeout
from eventlet.green import httplib, socket, urllib2
import json
from six.moves import range
from six.moves import urllib
import struct
from sys import exc_info
import zlib
from swift import gettext_ as _
from time import gmtime, strftime, time
import urlparse
from zlib import compressobj
from swift.common.utils import quote
@ -760,7 +760,7 @@ class SimpleClient(object):
req = urllib2.Request(url, headers=headers, data=contents)
if proxy:
proxy = urlparse.urlparse(proxy)
proxy = urllib.parse.urlparse(proxy)
req.set_proxy(proxy.netloc, proxy.scheme)
req.get_method = lambda: method
conn = urllib2.urlopen(req, timeout=timeout)

View File

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from six.moves.urllib.parse import quote, unquote
import tarfile
from urllib import quote, unquote
from xml.sax import saxutils
from time import time
from eventlet import sleep

View File

@ -17,6 +17,7 @@ import os
import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from six.moves.urllib.parse import unquote
from hashlib import md5
from swift.common import constraints
@ -29,7 +30,6 @@ from swift.common.utils import get_logger, json, \
closing_if_possible
from swift.common.request_helpers import SegmentedIterable
from swift.common.wsgi import WSGIContext, make_subrequest
from urllib import unquote
class GetContext(WSGIContext):

View File

@ -115,8 +115,8 @@ __all__ = ['FormPost', 'filter_factory', 'READ_CHUNK_SIZE', 'MAX_VALUE_LENGTH']
import hmac
from hashlib import sha1
from time import time
from urllib import quote
from six.moves.urllib.parse import quote
from swift.common.exceptions import MimeInvalid
from swift.common.middleware.tempurl import get_tempurl_keys_from_metadata
from swift.common.utils import streq_const_time, register_swift_info, \

View File

@ -78,7 +78,8 @@ with this middleware enabled should not be open to an untrusted
environment (everyone can query the locality data using this middleware).
"""
from urllib import quote, unquote
from six.moves.urllib.parse import quote, unquote
from swift.common.ring import Ring
from swift.common.utils import json, get_logger, split_path

View File

@ -40,9 +40,10 @@ The filter returns HTTPBadRequest if path is invalid.
@author: eamonn-otoole
'''
from six.moves.urllib.parse import unquote
import re
from swift.common.utils import get_logger
from urllib2 import unquote
from swift.common.swob import Request, HTTPBadRequest

View File

@ -73,8 +73,8 @@ bandwidth usage will want to only sum up logs with no swift.source.
import sys
import time
from urllib import quote, unquote
from six.moves.urllib.parse import quote, unquote
from swift.common.swob import Request
from swift.common.utils import (get_logger, get_remote_client,
get_valid_utf8_str, config_true_value,

View File

@ -17,13 +17,13 @@ from __future__ import print_function
from time import time
from traceback import format_exc
from urllib import unquote
from uuid import uuid4
from hashlib import sha1
import hmac
import base64
from eventlet import Timeout
from six.moves.urllib.parse import unquote
from swift.common.swob import Response, Request
from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
HTTPUnauthorized

View File

@ -118,8 +118,9 @@ __all__ = ['TempURL', 'filter_factory',
from os.path import basename
from time import time
from urllib import urlencode
from urlparse import parse_qs
from six.moves.urllib.parse import parse_qs
from six.moves.urllib.parse import urlencode
from swift.proxy.controllers.base import get_account_info, get_container_info
from swift.common.swob import HeaderKeyDict, HTTPUnauthorized, HTTPBadRequest

View File

@ -114,8 +114,8 @@ Disable versioning from a container (x is any value except empty)::
"""
import six
from six.moves.urllib.parse import quote, unquote
import time
from urllib import quote, unquote
from swift.common.utils import get_logger, Timestamp, json, \
register_swift_info, config_true_value
from swift.common.request_helpers import get_sys_meta_prefix

View File

@ -24,9 +24,9 @@ import hashlib
import itertools
import sys
import time
from urllib import unquote
import six
from six.moves.urllib.parse import unquote
from swift import gettext_ as _
from swift.common.storage_policy import POLICIES

View File

@ -33,7 +33,7 @@ from paste.deploy import loadwsgi
from eventlet.green import socket, ssl, os as green_os
from six import BytesIO
from six import StringIO
from urllib import unquote
from six.moves.urllib.parse import unquote
from swift.common import utils, constraints
from swift.common.storage_policy import BindPortsCache

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
from six.moves import urllib
from random import random
from time import time
from os.path import join
@ -290,7 +291,7 @@ class ObjectExpirer(Daemon):
:param timestamp: The timestamp the X-Delete-At value must match to
perform the actual delete.
"""
path = '/v1/' + urllib.quote(actual_obj.lstrip('/'))
path = '/v1/' + urllib.parse.quote(actual_obj.lstrip('/'))
self.swift.make_request('DELETE', path,
{'X-If-Delete-At': str(timestamp)},
(2, HTTP_PRECONDITION_FAILED))

View File

@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
import eventlet
import eventlet.wsgi
import eventlet.greenio
from six.moves import urllib
from swift.common import exceptions
from swift.common import http
@ -38,11 +38,12 @@ def decode_missing(line):
"""
result = {}
parts = line.split()
result['object_hash'], t_data = (urllib.unquote(v) for v in parts[:2])
result['object_hash'] = urllib.parse.unquote(parts[0])
t_data = urllib.parse.unquote(parts[1])
result['ts_data'] = result['ts_meta'] = Timestamp(t_data)
if len(parts) > 2:
# allow for a comma separated list of k:v pairs to future-proof
subparts = urllib.unquote(parts[2]).split(',')
subparts = urllib.parse.unquote(parts[2]).split(',')
for item in [subpart for subpart in subparts if ':' in subpart]:
k, v = item.split(':')
if k == 'm':
@ -78,7 +79,7 @@ def encode_wanted(remote, local):
# this is the inverse of _decode_wanted's key_map
key_map = dict(data='d', meta='m')
parts = ''.join(v for k, v in sorted(key_map.items()) if want.get(k))
return '%s %s' % (urllib.quote(remote['object_hash']), parts)
return '%s %s' % (urllib.parse.quote(remote['object_hash']), parts)
return None

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
from six.moves import urllib
from itertools import ifilter
from swift.common import bufferedhttp
from swift.common import exceptions
@ -29,7 +30,9 @@ def encode_missing(object_hash, ts_data, ts_meta=None):
The decoder for this line is
:py:func:`~swift.obj.ssync_receiver.decode_missing`
"""
msg = '%s %s' % (urllib.quote(object_hash), urllib.quote(ts_data.internal))
msg = ('%s %s'
% (urllib.parse.quote(object_hash),
urllib.parse.quote(ts_data.internal)))
if ts_meta and ts_meta != ts_data:
delta = ts_meta.raw - ts_data.raw
msg = '%s m:%x' % (msg, delta)
@ -318,14 +321,14 @@ class Sender(object):
msg = ':UPDATES: START\r\n'
self.connection.send('%x\r\n%s\r\n' % (len(msg), msg))
for object_hash, want in self.send_map.items():
object_hash = urllib.unquote(object_hash)
object_hash = urllib.parse.unquote(object_hash)
try:
df = self.df_mgr.get_diskfile_from_hash(
self.job['device'], self.job['partition'], object_hash,
self.job['policy'], frag_index=self.job.get('frag_index'))
except exceptions.DiskFileNotExist:
continue
url_path = urllib.quote(
url_path = urllib.parse.quote(
'/%s/%s/%s' % (df.account, df.container, df.obj))
try:
df.open()

View File

@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from six.moves.urllib.parse import unquote
from swift import gettext_ as _
from urllib import unquote
from swift.account.utils import account_listing_response
from swift.common.request_helpers import get_listing_content_type

View File

@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise.
from six.moves.urllib.parse import quote
import os
import time
import functools
@ -32,7 +34,6 @@ import itertools
import operator
from sys import exc_info
from swift import gettext_ as _
from urllib import quote
from eventlet import sleep
from eventlet.timeout import Timeout

View File

@ -14,9 +14,9 @@
# limitations under the License.
from swift import gettext_ as _
from urllib import unquote
import time
from six.moves.urllib.parse import unquote
from swift.common.utils import public, csv_append, Timestamp
from swift.common.constraints import check_metadata
from swift.common import constraints

View File

@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise.
from six.moves.urllib.parse import unquote, quote
import collections
import itertools
import mimetypes
@ -32,7 +34,6 @@ import math
import random
from hashlib import md5
from swift import gettext_ as _
from urllib import unquote, quote
from greenlet import GreenletExit
from eventlet import GreenPile

View File

@ -16,6 +16,7 @@
from __future__ import print_function
import mock
import os
from six.moves.urllib.parse import urlparse
import sys
import pickle
import socket
@ -26,7 +27,6 @@ import functools
import random
from time import time, sleep
from urlparse import urlparse
from nose import SkipTest
from contextlib import closing
from gzip import GzipFile

View File

@ -18,7 +18,6 @@ import os
import random
import socket
import time
import urllib
import simplejson as json
from nose import SkipTest
@ -26,6 +25,7 @@ from xml.dom import minidom
import six
from six.moves import http_client
from six.moves import urllib
from swiftclient import get_auth
from swift.common import constraints
@ -220,7 +220,7 @@ class Connection(object):
return '/' + self.storage_url.split('/')[1]
if path:
quote = urllib.quote
quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_path_quote'):
quote = lambda x: x
return '%s/%s' % (self.storage_url,
@ -260,7 +260,7 @@ class Connection(object):
path = self.make_path(path, cfg=cfg)
headers = self.make_headers(hdrs, cfg=cfg)
if isinstance(parms, dict) and parms:
quote = urllib.quote
quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y)))
@ -328,7 +328,7 @@ class Connection(object):
headers.pop('Content-Length', None)
if isinstance(parms, dict) and parms:
quote = urllib.quote
quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y)))
@ -698,7 +698,7 @@ class File(Base):
headers.update(hdrs)
if 'Destination' in headers:
headers['Destination'] = urllib.quote(headers['Destination'])
headers['Destination'] = urllib.parse.quote(headers['Destination'])
return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201
@ -722,9 +722,9 @@ class File(Base):
if 'Destination-Account' in headers:
headers['Destination-Account'] = \
urllib.quote(headers['Destination-Account'])
urllib.parse.quote(headers['Destination-Account'])
if 'Destination' in headers:
headers['Destination'] = urllib.quote(headers['Destination'])
headers['Destination'] = urllib.parse.quote(headers['Destination'])
return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201

View File

@ -22,9 +22,9 @@ import json
import locale
import random
import six
from six.moves import urllib
import time
import unittest
import urllib
import uuid
from copy import deepcopy
import eventlet
@ -281,7 +281,7 @@ class TestAccount(Base):
inserted_html = '<b>Hello World'
hax = 'AUTH_haxx"\nContent-Length: %d\n\n%s' % (len(inserted_html),
inserted_html)
quoted_hax = urllib.quote(hax)
quoted_hax = urllib.parse.quote(hax)
conn.connection.request('GET', '/v1/' + quoted_hax, None, {})
resp = conn.connection.getresponse()
resp_headers = dict(resp.getheaders())
@ -3152,7 +3152,7 @@ class TestTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
'%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
'%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):
@ -3441,7 +3441,7 @@ class TestContainerTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
'%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
'%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):
@ -3706,7 +3706,7 @@ class TestSloTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
'%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
'%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):

View File

@ -16,10 +16,10 @@ import sys
import itertools
import uuid
from optparse import OptionParser
from urlparse import urlparse
import random
import six
from six.moves.urllib.parse import urlparse
from swift.common.manager import Manager
from swift.common import utils, ring

View File

@ -18,9 +18,9 @@ import re
import unittest
from six.moves import http_client
from six.moves.urllib.parse import urlparse
from swiftclient import get_auth
from test.probe.common import ReplProbeTest
from urlparse import urlparse
class TestAccountGetFakeResponsesMatch(ReplProbeTest):

View File

@ -13,11 +13,11 @@
# limitations under the License.
import uuid
from urlparse import urlparse
import random
from nose import SkipTest
import unittest
from six.moves.urllib.parse import urlparse
from swiftclient import client
from swift.common.manager import Manager

View File

@ -23,10 +23,10 @@ import string
import tempfile
import time
import unittest
import urlparse
from eventlet.green import urllib2
from six import StringIO
from six.moves import urllib
from swift.cli import recon
from swift.common import utils
@ -342,7 +342,7 @@ class TestReconCommands(unittest.TestCase):
def mock_responses(self, resps):
def fake_urlopen(url, timeout):
scheme, netloc, path, _, _, _ = urlparse.urlparse(url)
scheme, netloc, path, _, _, _ = urllib.parse.urlparse(url)
self.assertEqual(scheme, 'http') # can't handle anything else
self.assertTrue(path.startswith('/recon/'))

View File

@ -15,10 +15,10 @@
# limitations under the License.
import numbers
from six.moves import urllib
import unittest
import os
import tarfile
import urllib
import zlib
import mock
import six
@ -763,10 +763,11 @@ class TestDelete(unittest.TestCase):
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(len(resp_data['Errors']), 2)
self.assertEquals(
resp_data['Errors'],
[[urllib.quote('c/ objbadutf8'), '412 Precondition Failed'],
[urllib.quote('/c/f\xdebadutf8'), '412 Precondition Failed']])
self.assertEquals(resp_data['Errors'],
[[urllib.parse.quote('c/ objbadutf8'),
'412 Precondition Failed'],
[urllib.parse.quote('/c/f\xdebadutf8'),
'412 Precondition Failed']])
def test_bulk_delete_no_body(self):
req = Request.blank('/unauth/AUTH_acc/')

View File

@ -14,11 +14,11 @@
# limitations under the License.
import unittest
from urllib import unquote
from logging.handlers import SysLogHandler
import mock
from six import BytesIO
from six.moves.urllib.parse import unquote
from test.unit import FakeLogger
from swift.common.utils import get_logger, split_path

View File

@ -16,13 +16,13 @@
import json
import unittest
import os
import urllib
from contextlib import contextmanager
from hashlib import md5
import time
import mock
import six
from six.moves import urllib
from swift.common import direct_client
from swift.common.exceptions import ClientException
@ -97,13 +97,13 @@ class TestDirectClient(unittest.TestCase):
self.account = u'\u062a account'
self.container = u'\u062a container'
self.obj = u'\u062a obj/name'
self.account_path = '/sda/0/%s' % urllib.quote(
self.account_path = '/sda/0/%s' % urllib.parse.quote(
self.account.encode('utf-8'))
self.container_path = '/sda/0/%s/%s' % tuple(
urllib.quote(p.encode('utf-8')) for p in (
urllib.parse.quote(p.encode('utf-8')) for p in (
self.account, self.container))
self.obj_path = '/sda/0/%s/%s/%s' % tuple(
urllib.quote(p.encode('utf-8')) for p in (
urllib.parse.quote(p.encode('utf-8')) for p in (
self.account, self.container, self.obj))
self.user_agent = 'direct-client %s' % os.getpid()

View File

@ -16,7 +16,6 @@
import json
import mock
import unittest
from urllib import quote
import zlib
from textwrap import dedent
import os
@ -24,6 +23,7 @@ import os
import six
from six import StringIO
from six.moves import range
from six.moves.urllib.parse import quote
from test.unit import FakeLogger
from eventlet.green import urllib2
from swift.common import internal_client

View File

@ -19,9 +19,9 @@ import datetime
import unittest
import re
import time
from urllib import quote
from six import BytesIO
from six.moves.urllib.parse import quote
import swift.common.swob
from swift.common import utils, exceptions

View File

@ -24,11 +24,11 @@ import os
from textwrap import dedent
from contextlib import nested
from collections import defaultdict
from urllib import quote
from eventlet import listen
from six import BytesIO
from six import StringIO
from six.moves.urllib.parse import quote
import mock

View File

@ -17,7 +17,6 @@ import mock
import operator
import time
import unittest
import urllib
import socket
import os
import errno
@ -26,6 +25,7 @@ import random
from collections import defaultdict
from datetime import datetime
from six.moves import urllib
from swift.container import reconciler
from swift.container.server import gen_resp_headers
from swift.common.direct_client import ClientException
@ -153,7 +153,7 @@ class FakeInternalClient(reconciler.InternalClient):
obj_name = container_listing_data[-1]['name']
# client should quote and encode marker
end_qry_string = '?format=json&marker=%s&end_marker=' % (
urllib.quote(obj_name.encode('utf-8')))
urllib.parse.quote(obj_name.encode('utf-8')))
self.app.register('GET', container_path + end_qry_string,
swob.HTTPOk, container_headers,
json.dumps([]))
@ -170,7 +170,7 @@ class FakeInternalClient(reconciler.InternalClient):
swob.HTTPOk, account_headers,
json.dumps(account_listing_data))
end_qry_string = '?format=json&marker=%s&end_marker=' % (
urllib.quote(account_listing_data[-1]['name']))
urllib.parse.quote(account_listing_data[-1]['name']))
self.app.register('GET', account_path + end_qry_string,
swob.HTTPOk, account_headers,
json.dumps([]))
@ -685,7 +685,7 @@ class TestReconcilerUtils(unittest.TestCase):
def listing_qs(marker):
return "?format=json&marker=%s&end_marker=" % \
urllib.quote(marker.encode('utf-8'))
urllib.parse.quote(marker.encode('utf-8'))
class TestReconciler(unittest.TestCase):

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
from time import time
from unittest import main, TestCase
from test.unit import FakeRing, mocked_http_conn, debug_logger
@ -23,6 +22,7 @@ from shutil import rmtree
import mock
import six
from six.moves import urllib
from swift.common import internal_client, utils
from swift.obj import expirer
@ -746,7 +746,7 @@ class TestObjectExpirer(TestCase):
x.delete_actual_object(name, timestamp)
self.assertEqual(x.swift.make_request.call_count, 1)
self.assertEqual(x.swift.make_request.call_args[0][1],
'/v1/' + urllib.quote(name))
'/v1/' + urllib.parse.quote(name))
def test_pop_queue(self):
class InternalClient(object):

View File

@ -20,12 +20,12 @@ import shutil
import tempfile
import time
import unittest
import urllib
import eventlet
import itertools
import mock
import six
from six.moves import urllib
from swift.common import exceptions, utils
from swift.common.storage_policy import POLICIES
@ -2368,7 +2368,8 @@ class TestSsyncReplication(TestBaseSsync):
def _legacy_check_missing(self, line):
# reproduces behavior of 'legacy' ssync receiver missing_checks()
parts = line.split()
object_hash, timestamp = [urllib.unquote(v) for v in parts[:2]]
object_hash = urllib.parse.unquote(parts[0])
timestamp = urllib.parse.unquote(parts[1])
want = False
try:
df = self.diskfile_mgr.get_diskfile_from_hash(
@ -2386,7 +2387,7 @@ class TestSsyncReplication(TestBaseSsync):
else:
want = df.timestamp < timestamp
if want:
return urllib.quote(object_hash)
return urllib.parse.quote(object_hash)
return None
# run the sync protocol...

View File

@ -28,7 +28,6 @@ from shutil import rmtree
import gc
import time
from textwrap import dedent
from urllib import quote
from hashlib import md5
from pyeclib.ec_iface import ECDriverError
from tempfile import mkdtemp, NamedTemporaryFile
@ -46,6 +45,8 @@ from eventlet.green import httplib
from six import BytesIO
from six import StringIO
from six.moves import range
from six.moves.urllib.parse import quote
from swift.common.utils import hash_path, json, storage_directory, \
parse_content_type, parse_mime_headers, \
iter_multipart_mime_documents, public

View File

@ -12,10 +12,12 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from six.moves.urllib.parse import quote
import unittest
import os
from tempfile import mkdtemp
from urllib import quote
import shutil
from swift.common.storage_policy import StoragePolicy
from swift.common.swob import Request