Remove six
Remove six Replace the following items with Python 3 style code. - six.PY3 - six.moves.urllib - six.PY2 - six.text_type - six.string_types - six.iterkeys - six.moves.range - six.add_metaclass - six.moves.map - six.moves.zip - six.MAXSIZE Change-Id: I4cd26693fac7c16f4fa3d3c0015cd7af796f0877changes/33/765433/7
parent
40b5633dfd
commit
88a4be5e5c
|
@ -30,7 +30,6 @@ import dns.rcode
|
|||
import dns.message
|
||||
import dns.flags
|
||||
import dns.opcode
|
||||
import six
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -106,7 +105,7 @@ class RequestHandler(object):
|
|||
question = request.question[0]
|
||||
requester = request.environ['addr'][0]
|
||||
zone_name = question.name.to_text()
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
if not self._allowed(request, requester, "CREATE", zone_name):
|
||||
|
@ -159,7 +158,7 @@ class RequestHandler(object):
|
|||
question = request.question[0]
|
||||
requester = request.environ['addr'][0]
|
||||
zone_name = question.name.to_text()
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
if not self._allowed(request, requester, "NOTIFY", zone_name):
|
||||
|
@ -212,7 +211,7 @@ class RequestHandler(object):
|
|||
question = request.question[0]
|
||||
requester = request.environ['addr'][0]
|
||||
zone_name = question.name.to_text()
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
if not self._allowed(request, requester, "DELETE", zone_name):
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
import pecan
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -77,10 +76,7 @@ class ZoneImportController(rest.RestController):
|
|||
request = pecan.request
|
||||
response = pecan.response
|
||||
context = request.environ['context']
|
||||
if six.PY2:
|
||||
body = request.body
|
||||
else:
|
||||
body = request.body.decode('utf-8')
|
||||
body = request.body.decode('utf-8')
|
||||
|
||||
if request.content_type != 'text/dns':
|
||||
raise exceptions.UnsupportedContentType(
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
from oslo_serialization import jsonutils
|
||||
import pecan.core
|
||||
|
||||
|
@ -46,4 +45,4 @@ class Request(pecan.core.Request):
|
|||
if not self.body:
|
||||
raise exceptions.EmptyRequestBody('Request Body is empty')
|
||||
else:
|
||||
raise exceptions.InvalidJson(six.text_type(e))
|
||||
raise exceptions.InvalidJson(str(e))
|
||||
|
|
|
@ -17,7 +17,6 @@ import os
|
|||
|
||||
import dns
|
||||
import dns.resolver
|
||||
import six
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -87,7 +86,7 @@ class Bind9Backend(base.AgentBackend):
|
|||
# NOTE: Different versions of BIND9 behave differently with a trailing
|
||||
# dot, so we're just going to take it off.
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
# NOTE: Only one thread should be working with the Zonefile at a given
|
||||
|
|
|
@ -18,7 +18,6 @@ import itertools
|
|||
import dns.rdata
|
||||
import dns.rdatatype
|
||||
import dns.rdataclass
|
||||
import six
|
||||
from oslo_config import cfg
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
|
@ -122,7 +121,7 @@ class DenominatorBackend(base.AgentBackend):
|
|||
def create_zone(self, zone):
|
||||
LOG.debug("Creating %s", zone.origin.to_text())
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
# Use SOA TTL as zone default TTL
|
||||
|
@ -156,7 +155,7 @@ class DenominatorBackend(base.AgentBackend):
|
|||
def update_zone(self, zone):
|
||||
LOG.debug("Updating %s", zone.origin)
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
soa_record = zone.find_rrset(zone.origin, dns.rdatatype.SOA)
|
||||
|
@ -226,7 +225,7 @@ class DenominatorBackend(base.AgentBackend):
|
|||
for rname, ttl, rdata in zone.iterate_rdatas():
|
||||
name = rname.derelativize(origin=zone.origin)
|
||||
name = name.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
|
||||
data = rdata.to_text(origin=zone.origin, relativize=False)
|
||||
|
|
|
@ -46,7 +46,6 @@ import tempfile
|
|||
|
||||
import dns
|
||||
import dns.resolver
|
||||
import six
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_concurrency.processutils import ProcessExecutionError
|
||||
from oslo_config import cfg
|
||||
|
@ -274,7 +273,7 @@ class DjbdnsBackend(base.AgentBackend):
|
|||
:raises: exceptions.Backend on error
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Creating %s", zone_name)
|
||||
# The zone might be already in place due to a race condition between
|
||||
|
@ -295,7 +294,7 @@ class DjbdnsBackend(base.AgentBackend):
|
|||
:raises: exceptions.Backend on error
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Triggering AXFR from MiniDNS to Djbdns for %s", zone_name)
|
||||
self._perform_axfr_from_minidns(zone_name)
|
||||
|
|
|
@ -45,7 +45,6 @@ import string
|
|||
|
||||
import dns
|
||||
import dns.resolver
|
||||
import six
|
||||
from oslo_concurrency.processutils import ProcessExecutionError
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -166,7 +165,7 @@ class GdnsdBackend(base.AgentBackend):
|
|||
The zone file is written to a unique temp file and then renamed
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
zone_base_fname = self._generate_zone_filename(zone_name)
|
||||
zone_fname = os.path.join(self._zonedir_path, zone_base_fname)
|
||||
|
|
|
@ -37,7 +37,6 @@ Supported Knot versions: >= 2.1, < 3
|
|||
|
||||
Configured in [service:agent:knot2]
|
||||
"""
|
||||
import six
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_concurrency.processutils import ProcessExecutionError
|
||||
|
@ -172,7 +171,7 @@ class Knot2Backend(base.AgentBackend):
|
|||
:type zone: raw pythondns Zone
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Creating %s", zone_name)
|
||||
# The zone might be already in place due to a race condition between
|
||||
|
@ -192,7 +191,7 @@ class Knot2Backend(base.AgentBackend):
|
|||
:type zone: raw pythondns Zone
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Triggering AXFR from MiniDNS to Knot for %s", zone_name)
|
||||
self._start_minidns_to_knot_axfr(zone_name)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -64,7 +63,7 @@ class MSDNSBackend(base.AgentBackend):
|
|||
def create_zone(self, zone):
|
||||
"""Create a new DNS Zone"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Creating zone: %s", zone_name)
|
||||
try:
|
||||
|
@ -91,7 +90,7 @@ class MSDNSBackend(base.AgentBackend):
|
|||
"""Instruct MSDNS to request an AXFR from MiniDNS.
|
||||
"""
|
||||
zone_name = zone.origin.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
LOG.debug("Updating zone: %s", zone_name)
|
||||
self._dnsutils.zone_update(zone_name)
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
# under the License.
|
||||
|
||||
import time
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import requests
|
||||
from akamai import edgegrid
|
||||
from oslo_log import log as logging
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from designate import exceptions
|
||||
from designate.backend import base
|
||||
|
|
|
@ -20,7 +20,6 @@ Bind 9 backend. Create and delete zones by executing rndc
|
|||
|
||||
import random
|
||||
|
||||
import six
|
||||
import subprocess
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
@ -101,7 +100,7 @@ class Bind9Backend(base.Backend):
|
|||
self._execute_rndc(rndc_op)
|
||||
except exceptions.Backend as e:
|
||||
# If create fails because the zone exists, don't reraise
|
||||
if "already exists" not in six.text_type(e):
|
||||
if "already exists" not in str(e):
|
||||
LOG.warning('RNDC call failure: %s', e)
|
||||
raise
|
||||
|
||||
|
@ -128,7 +127,7 @@ class Bind9Backend(base.Backend):
|
|||
self._execute_rndc(rndc_op)
|
||||
except exceptions.Backend as e:
|
||||
# If zone is already deleted, don't reraise
|
||||
if "not found" not in six.text_type(e):
|
||||
if "not found" not in str(e):
|
||||
LOG.warning('RNDC call failure: %s', e)
|
||||
raise
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from urllib import parse
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
from six.moves.urllib import parse
|
||||
import requests
|
||||
|
||||
from designate.backend.impl_infoblox import ibexceptions as exc
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
import gettext
|
||||
|
||||
import six
|
||||
|
||||
from designate import exceptions
|
||||
|
||||
_ = gettext.gettext
|
||||
|
@ -43,7 +41,7 @@ class InfobloxExceptionBase(exceptions.Backend):
|
|||
super(InfobloxExceptionBase, self).__init__(self.message)
|
||||
|
||||
def __unicode__(self):
|
||||
return six.text_type(self.msg)
|
||||
return str(self.msg)
|
||||
|
||||
def use_fatal_exceptions(self):
|
||||
return False
|
||||
|
|
|
@ -22,7 +22,6 @@ import random
|
|||
import socket
|
||||
import ssl
|
||||
|
||||
import six
|
||||
import eventlet
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -92,7 +91,7 @@ class NSD4Backend(base.Backend):
|
|||
self._execute_nsd4(command)
|
||||
except exceptions.Backend as e:
|
||||
# If create fails because the zone exists, don't reraise
|
||||
if "already exists" not in six.text_type(e):
|
||||
if "already exists" not in str(e):
|
||||
raise
|
||||
|
||||
def delete_zone(self, context, zone):
|
||||
|
@ -103,5 +102,5 @@ class NSD4Backend(base.Backend):
|
|||
self._execute_nsd4(command)
|
||||
except exceptions.Backend as e:
|
||||
# If zone is already deleted, don't reraise
|
||||
if "not found" not in six.text_type(e):
|
||||
if "not found" not in str(e):
|
||||
raise
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import urllib
|
||||
|
||||
import netaddr
|
||||
import requests
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from six.moves import urllib
|
||||
|
||||
from designate import exceptions
|
||||
from designate.backend import base
|
||||
|
|
|
@ -26,7 +26,6 @@ import random
|
|||
from random import SystemRandom
|
||||
import time
|
||||
|
||||
import six
|
||||
from eventlet import tpool
|
||||
from dns import zone as dnszone
|
||||
from dns import exception as dnsexception
|
||||
|
@ -2180,7 +2179,7 @@ class Service(service.RPCService):
|
|||
if 'ptrdname' in values.obj_what_changed() and\
|
||||
values['ptrdname'] is None:
|
||||
self._unset_floatingip_reverse(context, region, floatingip_id)
|
||||
elif isinstance(values['ptrdname'], six.string_types):
|
||||
elif isinstance(values['ptrdname'], str):
|
||||
return self._set_floatingip_reverse(
|
||||
context, region, floatingip_id, values)
|
||||
|
||||
|
@ -2742,8 +2741,6 @@ class Service(service.RPCService):
|
|||
|
||||
def _import(self, context, zone_import, request_body):
|
||||
# Dnspython needs a str instead of a unicode object
|
||||
if six.PY2:
|
||||
request_body = str(request_body)
|
||||
zone = None
|
||||
try:
|
||||
dnspython_zone = dnszone.from_text(
|
||||
|
@ -2777,7 +2774,7 @@ class Service(service.RPCService):
|
|||
except Exception as e:
|
||||
LOG.exception('An undefined error occurred during zone import')
|
||||
msg = 'An undefined error occurred. %s'\
|
||||
% six.text_type(e)[:130]
|
||||
% str(e)[:130]
|
||||
zone_import.message = msg
|
||||
zone_import.status = 'ERROR'
|
||||
|
||||
|
@ -2800,12 +2797,12 @@ class Service(service.RPCService):
|
|||
zone_import.message = 'Duplicate zone.'
|
||||
except exceptions.InvalidTTL as e:
|
||||
zone_import.status = 'ERROR'
|
||||
zone_import.message = six.text_type(e)
|
||||
zone_import.message = str(e)
|
||||
except Exception as e:
|
||||
LOG.exception('An undefined error occurred during zone '
|
||||
'import creation')
|
||||
msg = 'An undefined error occurred. %s'\
|
||||
% six.text_type(e)[:130]
|
||||
% str(e)[:130]
|
||||
zone_import.message = msg
|
||||
zone_import.status = 'ERROR'
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import socket
|
|||
import time
|
||||
from threading import Lock
|
||||
|
||||
import six
|
||||
import dns
|
||||
import dns.exception
|
||||
import dns.zone
|
||||
|
@ -150,7 +149,7 @@ class TsigInfoMiddleware(DNSMiddleware):
|
|||
|
||||
try:
|
||||
name = request.keyname.to_text(True)
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
criterion = {'name': name}
|
||||
tsigkey = self.storage.find_tsigkey(
|
||||
|
@ -179,7 +178,7 @@ class TsigKeyring(object):
|
|||
def get(self, key, default=None):
|
||||
try:
|
||||
name = key.to_text(True)
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
criterion = {'name': name}
|
||||
tsigkey = self.storage.find_tsigkey(
|
||||
|
@ -249,7 +248,7 @@ class LimitNotifyMiddleware(DNSMiddleware):
|
|||
return None
|
||||
|
||||
zone_name = request.question[0].name.to_text()
|
||||
if six.PY3 and isinstance(zone_name, bytes):
|
||||
if isinstance(zone_name, bytes):
|
||||
zone_name = zone_name.decode('utf-8')
|
||||
|
||||
if self.locker.acquire(zone_name):
|
||||
|
@ -274,12 +273,12 @@ def from_dnspython_zone(dnspython_zone):
|
|||
if soa.ttl == 0:
|
||||
soa.ttl = CONF['service:central'].min_ttl
|
||||
email = soa[0].rname.to_text(omit_final_dot=True)
|
||||
if six.PY3 and isinstance(email, bytes):
|
||||
if isinstance(email, bytes):
|
||||
email = email.decode('utf-8')
|
||||
email = email.replace('.', '@', 1)
|
||||
|
||||
name = dnspython_zone.origin.to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
|
||||
values = {
|
||||
|
@ -301,7 +300,7 @@ def from_dnspython_zone(dnspython_zone):
|
|||
def dnspyrecords_to_recordsetlist(dnspython_records):
|
||||
rrsets = objects.RecordSetList()
|
||||
|
||||
for rname in six.iterkeys(dnspython_records):
|
||||
for rname in dnspython_records.keys():
|
||||
for rdataset in dnspython_records[rname]:
|
||||
rrset = dnspythonrecord_to_recordset(rname, rdataset)
|
||||
|
||||
|
@ -316,7 +315,7 @@ def dnspythonrecord_to_recordset(rname, rdataset):
|
|||
record_type = rdatatype.to_text(rdataset.rdtype)
|
||||
|
||||
name = rname.to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
|
||||
# Create the other recordsets
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
|
||||
class DesignateException(Exception):
|
||||
|
@ -29,7 +28,7 @@ class DesignateException(Exception):
|
|||
|
||||
super(DesignateException, self).__init__(*args, **kwargs)
|
||||
|
||||
if args and isinstance(args[0], six.string_types):
|
||||
if args and isinstance(args[0], str):
|
||||
self.error_message = args[0]
|
||||
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import pycodestyle
|
|||
# D704: Found import of %s. This oslo library has been graduated!
|
||||
# D705: timeutils.utcnow() must be used instead of datetime.%s()
|
||||
# D706: Don't translate debug level logs
|
||||
# D707: basestring is not Python3-compatible, use six.string_types instead.
|
||||
# D708: Do not use xrange. Use range, or six.moves.range for large loops.
|
||||
# D707: basestring is not Python3-compatible, use str instead.
|
||||
# D708: Do not use xrange. Use range for large loops.
|
||||
# D709: LOG.audit is deprecated, please use LOG.info!
|
||||
|
||||
UNDERSCORE_IMPORT_FILES = []
|
||||
|
@ -129,14 +129,14 @@ def use_timeutils_utcnow(logical_line, filename):
|
|||
def check_no_basestring(logical_line):
|
||||
if re.search(r"\bbasestring\b", logical_line):
|
||||
msg = ("D707: basestring is not Python3-compatible, use "
|
||||
"six.string_types instead.")
|
||||
"str instead.")
|
||||
yield(0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_python3_xrange(logical_line):
|
||||
if re.search(r"\bxrange\s*\(", logical_line):
|
||||
yield(0, "D708: Do not use xrange. Use range, or six.moves.range for "
|
||||
yield(0, "D708: Do not use xrange. Use range for "
|
||||
"large loops.")
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import dns.rdataclass
|
|||
import dns.rdatatype
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from designate import exceptions
|
||||
from designate.central import rpcapi as central_api
|
||||
|
@ -111,7 +110,7 @@ class RequestHandler(xfr.XFRMixin):
|
|||
question = request.question[0]
|
||||
|
||||
name = question.name.to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
|
||||
criterion = {
|
||||
|
@ -209,7 +208,7 @@ class RequestHandler(xfr.XFRMixin):
|
|||
# validate the parameters
|
||||
try:
|
||||
name = q_rrset.name.to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
criterion = self._zone_criterion_from_request(
|
||||
request, {'name': name})
|
||||
|
@ -307,7 +306,7 @@ class RequestHandler(xfr.XFRMixin):
|
|||
try:
|
||||
q_rrset = request.question[0]
|
||||
name = q_rrset.name.to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
# TODO(vinod) once validation is separated from the api,
|
||||
# validate the parameters
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
import eventlet.patcher
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from designate import exceptions
|
||||
from designate.plugin import DriverPlugin
|
||||
|
@ -142,6 +141,6 @@ class NetworkAPI(DriverPlugin):
|
|||
Get the name for the address
|
||||
"""
|
||||
name = reversename.from_address(address).to_text()
|
||||
if six.PY3 and isinstance(name, bytes):
|
||||
if isinstance(name, bytes):
|
||||
name = name.decode('utf-8')
|
||||
return name
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
from oslo_log import log as logging
|
||||
|
||||
from designate.utils import generate_uuid
|
||||
|
@ -41,7 +40,7 @@ def allocate_floatingip(project_id, floatingip_id=None):
|
|||
"""
|
||||
ALLOCATIONS.setdefault(project_id, {})
|
||||
|
||||
id_ = floatingip_id or list(six.iterkeys(POOL))[0]
|
||||
id_ = floatingip_id or list(POOL.keys())[0]
|
||||
|
||||
ALLOCATIONS[project_id][id_] = POOL.pop(id_)
|
||||
values = _format_floatingip(id_, ALLOCATIONS[project_id][id_])
|
||||
|
|
|
@ -19,7 +19,6 @@ import abc
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
import designate.conf
|
||||
from designate.plugin import DriverPlugin
|
||||
|
@ -152,7 +151,7 @@ class Audit(NotificationPlugin):
|
|||
# Just in case something odd makes it here
|
||||
if any(not isinstance(val,
|
||||
(int, float, bool,
|
||||
six.string_types, type(None)))
|
||||
str, type(None)))
|
||||
for val in (old_value, new_value)):
|
||||
LOG.warning("Nulling notification values after "
|
||||
"unexpected values (%s, %s)",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
from oslo_config import cfg
|
||||
|
||||
from designate.objects.adapters import base
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from designate.objects.adapters.api_v2 import base
|
||||
from designate import objects
|
||||
|
||||
|
@ -43,7 +41,7 @@ class PoolAttributeAPIv2Adapter(base.APIv2Adapter):
|
|||
|
||||
@classmethod
|
||||
def _parse_object(cls, values, object, *args, **kwargs):
|
||||
for key in six.iterkeys(values):
|
||||
for key in values.keys():
|
||||
object.key = key
|
||||
object.value = values[key]
|
||||
|
||||
|
@ -71,7 +69,7 @@ class PoolAttributeListAPIv2Adapter(base.APIv2Adapter):
|
|||
value = cls.get_object_adapter(
|
||||
cls.ADAPTER_FORMAT,
|
||||
object).render(cls.ADAPTER_FORMAT, object, *args, **kwargs)
|
||||
for key in six.iterkeys(value):
|
||||
for key in value.keys():
|
||||
r_list[key] = value[key]
|
||||
|
||||
return r_list
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from designate.objects.adapters.api_v2 import base
|
||||
from designate import objects
|
||||
|
||||
|
@ -43,7 +41,7 @@ class ZoneAttributeAPIv2Adapter(base.APIv2Adapter):
|
|||
|
||||
@classmethod
|
||||
def _parse_object(cls, values, object, *args, **kwargs):
|
||||
for key in six.iterkeys(values):
|
||||
for key in values.keys():
|
||||
object.key = key
|
||||
object.value = values[key]
|
||||
|
||||
|
@ -71,7 +69,7 @@ class ZoneAttributeListAPIv2Adapter(base.APIv2Adapter):
|
|||
value = cls.get_object_adapter(
|
||||
cls.ADAPTER_FORMAT,
|
||||
object).render(cls.ADAPTER_FORMAT, object, *args, **kwargs)
|
||||
for key in six.iterkeys(value):
|
||||
for key in value.keys():
|
||||
r_list[key] = value[key]
|
||||
|
||||
return r_list
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
import datetime
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
from oslo_versionedobjects import fields
|
||||
|
||||
from designate import objects
|
||||
|
@ -43,8 +42,7 @@ class DesignateObjectAdapterMetaclass(type):
|
|||
)
|
||||
|
||||
|
||||
@six.add_metaclass(DesignateObjectAdapterMetaclass)
|
||||
class DesignateAdapter(object):
|
||||
class DesignateAdapter(object, metaclass=DesignateObjectAdapterMetaclass):
|
||||
"""docstring for DesignateObjectAdapter"""
|
||||
|
||||
ADAPTER_OBJECT = objects.DesignateObject
|
||||
|
@ -66,7 +64,7 @@ class DesignateAdapter(object):
|
|||
try:
|
||||
return cls._adapter_classes[key]
|
||||
except KeyError as e:
|
||||
keys = six.text_type(e).split(':')
|
||||
keys = str(e).split(':')
|
||||
msg = "Adapter for %(object)s to format %(format)s not found" % {
|
||||
"object": keys[1],
|
||||
"format": keys[0]
|
||||
|
@ -196,7 +194,7 @@ class DesignateAdapter(object):
|
|||
})
|
||||
error_message = (u'Provided object is not valid. '
|
||||
u'Got a TypeError with message {}'.format(
|
||||
six.text_type(e)))
|
||||
str(e)))
|
||||
raise exceptions.InvalidObject(error_message)
|
||||
|
||||
except AttributeError as e:
|
||||
|
@ -208,7 +206,7 @@ class DesignateAdapter(object):
|
|||
})
|
||||
error_message = (u'Provided object is not valid. '
|
||||
u'Got an AttributeError with message {}'.format(
|
||||
six.text_type(e)))
|
||||
str(e)))
|
||||
raise exceptions.InvalidObject(error_message)
|
||||
|
||||
except exceptions.InvalidObject:
|
||||
|
@ -229,7 +227,7 @@ class DesignateAdapter(object):
|
|||
})
|
||||
error_message = (u'Provided object is not valid. '
|
||||
u'Got a {} error with message {}'.format(
|
||||
type(e).__name__, six.text_type(e)))
|
||||
type(e).__name__, str(e)))
|
||||
raise exceptions.InvalidObject(error_message)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from designate.objects.adapters.yaml import base
|
||||
from designate import objects
|
||||
|
||||
|
@ -38,7 +36,7 @@ class PoolAttributeYAMLAdapter(base.YAMLAdapter):
|
|||
|
||||
@classmethod
|
||||
def _parse_object(cls, values, object, *args, **kwargs):
|
||||
for key in six.iterkeys(values):
|
||||
for key in values.keys():
|
||||
object.key = key
|
||||
object.value = values[key]
|
||||
|
||||
|
@ -60,7 +58,7 @@ class PoolAttributeListYAMLAdapter(base.YAMLAdapter):
|
|||
value = cls.get_object_adapter(
|
||||
cls.ADAPTER_FORMAT,
|
||||
object).render(cls.ADAPTER_FORMAT, object, *args, **kwargs)
|
||||
for key in six.iterkeys(value):
|
||||
for key in value.keys():
|
||||
r_list[key] = value[key]
|
||||
|
||||
return r_list
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from designate.objects.adapters.yaml import base
|
||||
from designate import objects
|
||||
|
||||
|
@ -38,7 +36,7 @@ class PoolTargetOptionYAMLAdapter(base.YAMLAdapter):
|
|||
|
||||
@classmethod
|
||||
def _parse_object(cls, values, object, *args, **kwargs):
|
||||
for key in six.iterkeys(values):
|
||||
for key in values.keys():
|
||||
object.key = key
|
||||
object.value = values[key]
|
||||
|
||||
|
@ -60,7 +58,7 @@ class PoolTargetOptionListYAMLAdapter(base.YAMLAdapter):
|
|||
value = cls.get_object_adapter(
|
||||
cls.ADAPTER_FORMAT,
|
||||
object).render(cls.ADAPTER_FORMAT, object, *args, **kwargs)
|
||||
for key in six.iterkeys(value):
|
||||
for key in value.keys():
|
||||
r_list[key] = value[key]
|
||||
|
||||
return r_list
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
from oslo_log import log as logging
|
||||
from oslo_versionedobjects import exception
|
||||
from oslo_utils import excutils
|
||||
|
@ -133,7 +132,7 @@ class DesignateObject(base.VersionedObject):
|
|||
if not (name[0:5] == '_obj_' or
|
||||
name[0:7] == '_change' or
|
||||
name == '_context' or
|
||||
name in list(six.iterkeys(self.fields)) or
|
||||
name in list(self.fields.keys()) or
|
||||
name == 'FIELDS' or
|
||||
name == 'VERSION' or
|
||||
name == 'fields'):
|
||||
|
@ -245,7 +244,7 @@ class DesignateObject(base.VersionedObject):
|
|||
|
||||
def obj_get_original_value(self, field):
|
||||
"""Returns the original value of a field."""
|
||||
if field in list(six.iterkeys(self._obj_original_values)):
|
||||
if field in list(self._obj_original_values.keys()):
|
||||
return self._obj_original_values[field]
|
||||
elif self.obj_attr_is_set(field):
|
||||
return getattr(self, field)
|
||||
|
@ -487,7 +486,7 @@ class PagedListObjectMixin(object):
|
|||
|
||||
class DesignateRegistry(base.VersionedObjectRegistry):
|
||||
def registration_hook(self, cls, index):
|
||||
for name, field in six.iteritems(cls.fields):
|
||||
for name, field in cls.fields.items():
|
||||
attr = get_dict_attr(cls, name)
|
||||
|
||||
def getter(self, name=name):
|
||||
|
@ -511,7 +510,7 @@ class DesignateRegistry(base.VersionedObjectRegistry):
|
|||
# after OVO migration completed.
|
||||
if (self.obj_attr_is_set(name) and
|
||||
value != getattr(self, name) and
|
||||
name not in list(six.iterkeys(self._obj_original_values))): # noqa
|
||||
name not in list(self._obj_original_values.keys())): # noqa
|
||||
self._obj_original_values[name] = getattr(self, name)
|
||||
try:
|
||||
return setattr(self, attrname, field_value)
|
||||
|
|
|
@ -17,7 +17,6 @@ from copy import deepcopy
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import six
|
||||
from oslo_versionedobjects import exception as ovo_exc
|
||||
|
||||
from designate import exceptions
|
||||
|
@ -192,7 +191,7 @@ class RecordSet(base.DesignateObject, base.DictObjectMixin,
|
|||
|
||||
except Exception as e:
|
||||
error_message = ('Provided object is not valid. Got a %s error'
|
||||
' with message %s' % (type(e).__name__, six.text_type(e)))
|
||||
' with message %s' % (type(e).__name__, str(e)))
|
||||
raise exceptions.InvalidObject(error_message)
|
||||
|
||||
else:
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
# under the License.
|
||||
import abc
|
||||
|
||||
import six
|
||||
from stevedore import driver
|
||||
from stevedore import enabled
|
||||
from oslo_config import cfg
|
||||
|
@ -26,8 +25,7 @@ LOG = logging.getLogger(__name__)
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Plugin(object):
|
||||
class Plugin(object, metaclass=abc.ABCMeta):
|
||||
__plugin_ns__ = None
|
||||
|
||||
__plugin_name__ = None
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
# under the License.
|
||||
import abc
|
||||
|
||||
import six
|
||||
from oslo_config import cfg
|
||||
|
||||
from designate import exceptions
|
||||
from designate.plugin import DriverPlugin
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Quota(DriverPlugin):
|
||||
class Quota(DriverPlugin, metaclass=abc.ABCMeta):
|
||||
"""Base class for quota plugins"""
|
||||
__plugin_ns__ = 'designate.quota'
|
||||
__plugin_type__ = 'quota'
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -71,8 +70,7 @@ class StorageQuota(base.Quota):
|
|||
|
||||
self.storage.update_quota(context, quota)
|
||||
|
||||
if resource not in list(six.iterkeys(
|
||||
self.get_default_quotas(context))):
|
||||
if resource not in list(self.get_default_quotas(context).keys()):
|
||||
raise exceptions.QuotaResourceUnknown("%s is not a valid quota "
|
||||
"resource", resource)
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils.strutils import bool_from_string
|
||||
|
||||
|
@ -81,7 +80,7 @@ class AttributeFilter(base.Filter):
|
|||
return True
|
||||
|
||||
# Check if the keys requested exist in this pool
|
||||
if not {key for key in six.iterkeys(pool_attributes)}.issuperset(
|
||||
if not {key for key in pool_attributes.keys()}.issuperset(
|
||||
zone_attributes):
|
||||
msg = "%(pool)s did not match list of requested attribute "\
|
||||
"keys - removing from list. Requested: %(r_key)s. Pool:"\
|
||||
|
@ -98,7 +97,7 @@ class AttributeFilter(base.Filter):
|
|||
# Missing required keys - remove from the list
|
||||
return False
|
||||
|
||||
for key in six.iterkeys(zone_attributes):
|
||||
for key in zone_attributes.keys():
|
||||
LOG.debug("Checking value of %s for %s", key, pool)
|
||||
|
||||
pool_attr = bool_from_string(pool_attributes[key],
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
# under the License.
|
||||
import abc
|
||||
|
||||
import six
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Filter():
|
||||
class Filter(metaclass=abc.ABCMeta):
|
||||
"""This is the base class used for filtering Pools.
|
||||
|
||||
This class should implement a single public function
|
||||
|
|
|
@ -17,7 +17,6 @@ import abc
|
|||
import operator
|
||||
import threading
|
||||
|
||||
import six
|
||||
from oslo_db.sqlalchemy import utils as oslodb_utils
|
||||
from oslo_db import exception as oslo_db_exception
|
||||
from oslo_log import log as logging
|
||||
|
@ -36,9 +35,9 @@ LOG = logging.getLogger(__name__)
|
|||
def _set_object_from_model(obj, model, **extra):
|
||||
"""Update a DesignateObject with the values from a SQLA Model"""
|
||||
|
||||
for fieldname in six.iterkeys(obj.FIELDS):
|
||||
for fieldname in obj.FIELDS.keys():
|
||||
if hasattr(model, fieldname):
|
||||
if fieldname in six.iterkeys(extra):
|
||||
if fieldname in extra.keys():
|
||||
obj[fieldname] = extra[fieldname]
|
||||
else:
|
||||
obj[fieldname] = getattr(model, fieldname)
|
||||
|
@ -63,8 +62,7 @@ def _set_listobject_from_models(obj, models, map_=None):
|
|||
return obj
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class SQLAlchemy(object):
|
||||
class SQLAlchemy(object, metaclass=abc.ABCMeta):
|
||||
|
||||
def __init__(self):
|
||||
super(SQLAlchemy, self).__init__()
|
||||
|
@ -105,35 +103,35 @@ class SQLAlchemy(object):
|
|||
column = getattr(table.c, name)
|
||||
|
||||
# Wildcard value: '%'
|
||||
if isinstance(value, six.string_types) and '%' in value:
|
||||
if isinstance(value, str) and '%' in value:
|
||||
query = query.where(column.like(value))
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('!')):
|
||||
queryval = value[1:]
|
||||
query = query.where(column != queryval)
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('<=')):
|
||||
queryval = value[2:]
|
||||
query = query.where(column <= queryval)
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('<')):
|
||||
queryval = value[1:]
|
||||
query = query.where(column < queryval)
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('>=')):
|
||||
queryval = value[2:]
|
||||
query = query.where(column >= queryval)
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('>')):
|
||||
queryval = value[1:]
|
||||
query = query.where(column > queryval)
|
||||
|
||||
elif (isinstance(value, six.string_types) and
|
||||
elif (isinstance(value, str) and
|
||||
value.startswith('BETWEEN')):
|
||||
elements = [i.strip(" ") for i in
|
||||
value.split(" ", 1)[1].strip(" ").split(",")]
|
||||
|
@ -265,13 +263,13 @@ class SQLAlchemy(object):
|
|||
|
||||
return _set_listobject_from_models(list_cls(), results)
|
||||
except oslodb_utils.InvalidSortKey as sort_key_error:
|
||||
raise exceptions.InvalidSortKey(six.text_type(sort_key_error))
|
||||
raise exceptions.InvalidSortKey(str(sort_key_error))
|
||||
# Any ValueErrors are propagated back to the user as is.
|
||||
# Limits, sort_dir and sort_key are checked at the API layer.
|
||||
# If however central or storage is called directly, invalid values
|
||||
# show up as ValueError
|
||||
except ValueError as value_error:
|
||||
raise exceptions.ValueError(six.text_type(value_error))
|
||||
raise exceptions.ValueError(str(value_error))
|
||||
|
||||
def _find_recordsets_with_records(self, context, criterion, zones_table,
|
||||
recordsets_table, records_table,
|
||||
|
@ -322,13 +320,13 @@ class SQLAlchemy(object):
|
|||
sort_dir=sort_dir)
|
||||
|
||||
except oslodb_utils.InvalidSortKey as sort_key_error:
|
||||
raise exceptions.InvalidSortKey(six.text_type(sort_key_error))
|
||||
raise exceptions.InvalidSortKey(str(sort_key_error))
|
||||
# Any ValueErrors are propagated back to the user as is.
|
||||
# Limits, sort_dir and sort_key are checked at the API layer.
|
||||
# If however central or storage is called directly, invalid values
|
||||
# show up as ValueError
|
||||
except ValueError as value_error:
|
||||
raise exceptions.ValueError(six.text_type(value_error))
|
||||
raise exceptions.ValueError(str(value_error))
|
||||
|
||||
if apply_tenant_criteria:
|
||||
inner_q = self._apply_tenant_criteria(
|
||||
|
@ -365,7 +363,7 @@ class SQLAlchemy(object):
|
|||