Remove usage of six

... because this library no longer supports Python 2.

Change-Id: I483d20d08426d8c677e44c81249ebe8235ce37ed
This commit is contained in:
Takashi Kajinami 2024-01-25 22:15:20 +09:00
parent fdde6afa94
commit 34aa8194af
18 changed files with 40 additions and 96 deletions

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
ATTACHMENT_KEYNAME_TYPEURI = "typeURI"
@ -31,12 +29,10 @@ class Attachment(cadftype.CADFAbstractType):
# the set of approved attachment types in order to
# limit and validate them.
typeURI = cadftype.ValidatorDescriptor(ATTACHMENT_KEYNAME_TYPEURI,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
content = cadftype.ValidatorDescriptor(ATTACHMENT_KEYNAME_CONTENT)
name = cadftype.ValidatorDescriptor(ATTACHMENT_KEYNAME_NAME,
lambda x: isinstance(x,
six.string_types))
lambda x: isinstance(x, str))
def __init__(self, typeURI=None, content=None, name=None):
"""Create Attachment data type

View File

@ -15,7 +15,6 @@
import abc
from oslo_serialization import jsonutils
import six
CADF_SCHEMA_1_0_0 = 'cadf:'
CADF_VERSION_1_0_0 = 'http://schemas.dmtf.org/cloud/audit/1.0/'
@ -71,8 +70,7 @@ class ValidatorDescriptor(object):
raise ValueError('%s must not be None.' % self.name)
@six.add_metaclass(abc.ABCMeta)
class CADFAbstractType(object):
class CADFAbstractType(object, metaclass=abc.ABCMeta):
"""The abstract base class for all CADF (complex) data types (classes)."""
@abc.abstractmethod

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
from pycadf import utils
@ -36,12 +34,10 @@ FED_CRED_KEYNAMES = CRED_KEYNAMES + [FED_CRED_KEYNAME_IDENTITY_PROVIDER,
class Credential(cadftype.CADFAbstractType):
type = cadftype.ValidatorDescriptor(
CRED_KEYNAME_TYPE,
lambda x: isinstance(x, six.string_types))
token = cadftype.ValidatorDescriptor(
CRED_KEYNAME_TOKEN,
lambda x: isinstance(x, six.string_types))
type = cadftype.ValidatorDescriptor(CRED_KEYNAME_TYPE,
lambda x: isinstance(x, str))
token = cadftype.ValidatorDescriptor(CRED_KEYNAME_TOKEN,
lambda x: isinstance(x, str))
def __init__(self, token, type=None):
"""Create Credential data type
@ -67,10 +63,10 @@ class Credential(cadftype.CADFAbstractType):
class FederatedCredential(Credential):
identity_provider = cadftype.ValidatorDescriptor(
FED_CRED_KEYNAME_IDENTITY_PROVIDER,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
user = cadftype.ValidatorDescriptor(
FED_CRED_KEYNAME_USER,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
groups = cadftype.ValidatorDescriptor(
FED_CRED_KEYNAME_GROUPS,
lambda x: isinstance(x, list))

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
TYPE_URI_ENDPOINT = cadftype.CADF_VERSION_1_0_0 + 'endpoint'
@ -30,11 +28,11 @@ ENDPOINT_KEYNAMES = [ENDPOINT_KEYNAME_URL,
class Endpoint(cadftype.CADFAbstractType):
url = cadftype.ValidatorDescriptor(
ENDPOINT_KEYNAME_URL, lambda x: isinstance(x, six.string_types))
ENDPOINT_KEYNAME_URL, lambda x: isinstance(x, str))
name = cadftype.ValidatorDescriptor(
ENDPOINT_KEYNAME_NAME, lambda x: isinstance(x, six.string_types))
ENDPOINT_KEYNAME_NAME, lambda x: isinstance(x, str))
port = cadftype.ValidatorDescriptor(
ENDPOINT_KEYNAME_PORT, lambda x: isinstance(x, six.string_types))
ENDPOINT_KEYNAME_PORT, lambda x: isinstance(x, str))
def __init__(self, url, name=None, port=None):
"""Create Endpoint data type

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import attachment
from pycadf import cadftaxonomy
from pycadf import cadftype
@ -97,11 +95,9 @@ class Event(cadftype.CADFAbstractType):
EVENT_KEYNAME_REASON,
lambda x: isinstance(x, reason.Reason) and x.is_valid())
name = cadftype.ValidatorDescriptor(EVENT_KEYNAME_NAME,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
severity = cadftype.ValidatorDescriptor(EVENT_KEYNAME_SEVERITY,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
observer = cadftype.ValidatorDescriptor(
EVENT_KEYNAME_OBSERVER,
(lambda x: isinstance(x, resource.Resource) and x.is_valid()))

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
from pycadf import identifier
@ -50,26 +48,20 @@ class Geolocation(cadftype.CADFAbstractType):
# TODO(mrutkows): we may want to do more validation to make
# sure numeric range represented by string is valid
latitude = cadftype.ValidatorDescriptor(GEO_KEYNAME_LATITUDE,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
longitude = cadftype.ValidatorDescriptor(GEO_KEYNAME_LONGITUDE,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
elevation = cadftype.ValidatorDescriptor(GEO_KEYNAME_ELEVATION,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
accuracy = cadftype.ValidatorDescriptor(GEO_KEYNAME_ACCURACY,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
city = cadftype.ValidatorDescriptor(GEO_KEYNAME_CITY,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
state = cadftype.ValidatorDescriptor(GEO_KEYNAME_STATE,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
regionICANN = cadftype.ValidatorDescriptor(
GEO_KEYNAME_REGIONICANN,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
def __init__(self, id=None, latitude=None, longitude=None,
elevation=None, accuracy=None, city=None, state=None,

View File

@ -11,8 +11,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftaxonomy
@ -33,8 +31,8 @@ def convert_req_action(method, details=None):
'trace': 'capture'}
action = None
if isinstance(method, six.string_types):
if isinstance(method, str):
action = mapping.get(method.lower())
if action and isinstance(details, six.string_types):
if action and isinstance(details, str):
action += '/%s' % details
return action or cadftaxonomy.UNKNOWN

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
from pycadf import identifier
@ -35,11 +33,11 @@ class Host(cadftype.CADFAbstractType):
id = cadftype.ValidatorDescriptor(
HOST_KEYNAME_ID, lambda x: identifier.is_valid(x))
address = cadftype.ValidatorDescriptor(
HOST_KEYNAME_ADDR, lambda x: isinstance(x, six.string_types))
HOST_KEYNAME_ADDR, lambda x: isinstance(x, str))
agent = cadftype.ValidatorDescriptor(
HOST_KEYNAME_AGENT, lambda x: isinstance(x, six.string_types))
HOST_KEYNAME_AGENT, lambda x: isinstance(x, str))
platform = cadftype.ValidatorDescriptor(
HOST_KEYNAME_PLATFORM, lambda x: isinstance(x, six.string_types))
HOST_KEYNAME_PLATFORM, lambda x: isinstance(x, str))
def __init__(self, id=None, address=None, agent=None,
platform=None):

View File

@ -17,7 +17,6 @@ import uuid
import warnings
from oslo_config import cfg
import six
CONF = cfg.CONF
opts = [
@ -66,7 +65,7 @@ def is_valid(value):
try:
_check_valid_uuid(value)
except (ValueError, TypeError):
if not isinstance(value, six.string_types) or not value:
if not isinstance(value, str) or not value:
return False
warnings.warn(('Invalid uuid: %s. To ensure interoperability, '
'identifiers should be a valid uuid.' % (value)))

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
from pycadf import identifier
@ -38,11 +36,9 @@ class Metric(cadftype.CADFAbstractType):
metricId = cadftype.ValidatorDescriptor(METRIC_KEYNAME_METRICID,
lambda x: identifier.is_valid(x))
unit = cadftype.ValidatorDescriptor(METRIC_KEYNAME_UNIT,
lambda x: isinstance(x,
six.string_types))
lambda x: isinstance(x, str))
name = cadftype.ValidatorDescriptor(METRIC_KEYNAME_NAME,
lambda x: isinstance(x,
six.string_types))
lambda x: isinstance(x, str))
def __init__(self, metricId=None, unit=None, name=None):
"""Create metric data type

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
@ -30,7 +28,7 @@ class Path(cadftype.CADFAbstractType):
# TODO(mrutkows): validate any cadf:Path (type) record against CADF schema
@staticmethod
def is_valid(value):
if not isinstance(value, six.string_types):
if not isinstance(value, str):
raise TypeError
return True

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import cadftype
TYPE_URI_REASON = cadftype.CADF_VERSION_1_0_0 + 'reason'
@ -33,16 +31,16 @@ class Reason(cadftype.CADFAbstractType):
reasonType = cadftype.ValidatorDescriptor(
REASON_KEYNAME_REASONTYPE,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
reasonCode = cadftype.ValidatorDescriptor(
REASON_KEYNAME_REASONCODE,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
policyType = cadftype.ValidatorDescriptor(
REASON_KEYNAME_POLICYTYPE,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
policyId = cadftype.ValidatorDescriptor(
REASON_KEYNAME_POLICYID,
lambda x: isinstance(x, six.string_types))
lambda x: isinstance(x, str))
def __init__(self, reasonType=None, reasonCode=None, policyType=None,
policyId=None):

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
from pycadf import attachment
from pycadf import cadftaxonomy
from pycadf import cadftype
@ -57,11 +55,9 @@ class Resource(cadftype.CADFAbstractType):
id = cadftype.ValidatorDescriptor(RESOURCE_KEYNAME_ID,
lambda x: identifier.is_valid(x))
name = cadftype.ValidatorDescriptor(RESOURCE_KEYNAME_NAME,
lambda x: isinstance(x,
six.string_types))
lambda x: isinstance(x, str))
domain = cadftype.ValidatorDescriptor(RESOURCE_KEYNAME_DOMAIN,
lambda x: isinstance(
x, six.string_types))
lambda x: isinstance(x, str))
credential = cadftype.ValidatorDescriptor(
RESOURCE_KEYNAME_CRED, (lambda x: isinstance(x, credential.Credential)
and x.is_valid()))
@ -73,8 +69,7 @@ class Resource(cadftype.CADFAbstractType):
# in the past or a URL that is only valid within some domain (e.g. a
# private cloud)
ref = cadftype.ValidatorDescriptor(RESOURCE_KEYNAME_REF,
lambda x: isinstance(x,
six.string_types))
lambda x: isinstance(x, str))
geolocation = cadftype.ValidatorDescriptor(
RESOURCE_KEYNAME_GEO,
lambda x: isinstance(x, geolocation.Geolocation))

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
def generate_name_value_tag(name, value):
"""Generate a CADF tag in the format name?value=<value>
@ -32,6 +30,6 @@ def generate_name_value_tag(name, value):
def is_valid(value):
"""Validation check to ensure proper Tag format
"""
if not isinstance(value, six.string_types):
if not isinstance(value, str):
raise TypeError
return True

View File

@ -15,7 +15,6 @@
import datetime
import pytz
import six
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f%z"
@ -39,7 +38,7 @@ def get_utc_now(timezone=None):
def is_valid(value):
"""Validation to ensure timestamp is a string.
"""
if not isinstance(value, six.string_types):
if not isinstance(value, str):
raise ValueError('Timestamp should be a String')
return True

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations under
# the License.
import six
def mask_value(value, s_percent=0.125):
"""Obfuscate a given string to show only a percentage of leading
@ -21,7 +19,7 @@ def mask_value(value, s_percent=0.125):
:param s_percent: The percentage (in decimal) of characters to replace
"""
if isinstance(value, six.string_types):
if isinstance(value, str):
visible = (32 if int(round(len(value) * s_percent)) > 32
else int(round(len(value) * s_percent)))
return value[:visible] + " xxxxxxxx " + value[-visible:]

View File

@ -1,12 +1,7 @@
# Requirements lower bounds listed here are our best effort to keep them up to
# date but we do not test them so no guarantee of having them all correct. If
# you find any incorrect lower bounds, let us know or propose a fix.
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
oslo.config>=5.2.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
pytz>=2013.6 # MIT
six>=1.10.0 # MIT
debtcollector>=1.2.0 # Apache-2.0

View File

@ -1,7 +1,3 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking>=3.0.1,<3.1.0 # Apache-2.0
flake8-docstrings==1.6.0 # MIT