Merge "Remove six"

This commit is contained in:
Zuul 2021-06-22 23:34:12 +00:00 committed by Gerrit Code Review
commit 5a4f0982d6
44 changed files with 101 additions and 153 deletions

View File

@ -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):

View File

@ -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

View File

@ -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(

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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]

View File

@ -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.")

View File

@ -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

View File

@ -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

View File

@ -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_])

View File

@ -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)",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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

View File

@ -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'

View File

@ -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)

View File

@ -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],

View File

@ -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

View File

@ -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):
id_zname_map = {}
for r in rows:
id_zname_map[r[0]] = r[1]
formatted_ids = six.moves.map(operator.itemgetter(0), rows)
formatted_ids = map(operator.itemgetter(0), rows)
# Count query does not scale well for large amount of recordsets,
# don't do it if the header 'OpenStack-DNS-Hide-Counts: True' exists
@ -470,7 +468,7 @@ class SQLAlchemy(object):
# 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))
rrsets = objects.RecordSetList()
rrset_id = None
@ -621,4 +619,4 @@ class SQLAlchemy(object):
# 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))

View File

@ -16,7 +16,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import sqlalchemy
from sqlalchemy import exc as sqlalchemy_exc
from sqlalchemy import select
@ -111,7 +110,7 @@ def sort_query(query, table, sort_keys, sort_dir=None, sort_dirs=None):
assert(len(sort_dirs) == len(sort_keys))
for current_sort_key, current_sort_dir in \
six.moves.zip(sort_keys, sort_dirs):
zip(sort_keys, sort_dirs):
try:
sort_dir_func = {
'asc': sqlalchemy.asc,

View File

@ -15,13 +15,10 @@
# under the License.
import abc
import six
from designate.plugin import DriverPlugin
@six.add_metaclass(abc.ABCMeta)
class Storage(DriverPlugin):
class Storage(DriverPlugin, metaclass=abc.ABCMeta):
"""Base class for storage plugins"""
__plugin_ns__ = 'designate.storage'

View File

@ -18,8 +18,8 @@ import functools
import inspect
import os
import socket
import sys
import six
import pkg_resources
from jinja2 import Template
from oslo_config import cfg
@ -273,7 +273,7 @@ def get_paging_params(context, params, sort_keys):
sort_dir = params.pop('sort_dir', None)
max_limit = cfg.CONF['service:api'].max_limit_v2
if isinstance(limit, six.string_types) and limit.lower() == "max":
if isinstance(limit, str) and limit.lower() == "max":
# Support for retrieving the max results at once. If set to "max",
# the configured max limit will be used.
limit = max_limit
@ -287,7 +287,7 @@ def get_paging_params(context, params, sort_keys):
'%(max)s' % {'max': max_limit})
try:
int_limit = int(limit)
if int_limit <= 0 or int_limit > six.MAXSIZE:
if int_limit <= 0 or int_limit > sys.maxsize:
raise exceptions.InvalidLimit(invalid_limit_message)
# This exception is raised for non ints when int(limit) is called
except ValueError:

View File

@ -21,6 +21,7 @@ It is used via a single directive in the .rst file
.. support_matrix::
"""
import configparser as config_parser
import os
import sys
@ -28,8 +29,6 @@ from docutils import nodes
from docutils.parsers import rst
from sphinx.util import logging
from sphinx.util.osutil import copyfile
import six
import six.moves.configparser as config_parser
from designate.backend.base import Backend
from designate.backend.agent_backend.base import AgentBackend
@ -83,7 +82,7 @@ class SupportMatrixBackend(object):
class SupportMatrixDirective(rst.Directive):
option_spec = {
'support-matrix': six.text_type,
'support-matrix': str,
}
def run(self):
@ -274,7 +273,7 @@ class SupportMatrixDirective(rst.Directive):
content.append(detailstitle)
content.append(nodes.paragraph())
for key in six.iterkeys(matrix.backends):
for key in matrix.backends.keys():
content.append(
nodes.subtitle(text=matrix.backends[key].title))
content.append(
@ -378,7 +377,7 @@ class SupportMatrixDirective(rst.Directive):
summaryhead.append(header)
grades = matrix.grades
impls = list(six.iterkeys(matrix.backends))
impls = list(matrix.backends.keys())
impls.sort()
for grade in grades:
for backend in impls:

View File

@ -124,7 +124,6 @@ restructuredtext-lint==1.1.3
rfc3986==1.2.0
Routes==2.4.1
simplejson==3.13.2
six==1.11.0
smmap2==2.0.3
snowballstemmer==1.2.1
sqlalchemy-migrate==0.11.0

View File

@ -30,7 +30,6 @@ python-designateclient>=2.12.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0
requests>=2.23.0 # Apache-2.0
tenacity>=6.0.0 # Apache-2.0
six>=1.11.0 # MIT
SQLAlchemy>=1.2.19 # MIT
sqlalchemy-migrate>=0.11.0 # Apache-2.0
stevedore>=1.20.0 # Apache-2.0