Remove six
Replace the following items with Python 3 style code. - six.moves - six.add_metaclass - six.PY3 - six.text_type - six.string_type - six.string_types - six.iteritems - six.integer_types Implements: blueprint six-removal Change-Id: Ifdb5ffad4203f14c58959b87338d0de34af76674
This commit is contained in:
parent
213087869a
commit
335aa966f3
@ -14,7 +14,6 @@ Cloudkitty Specific Commandments
|
||||
- [C312] Use assertTrue(...) rather than assertEqual(True, ...).
|
||||
- [C313] Validate that logs are not translated.
|
||||
- [C314] str() and unicode() cannot be used on an exception.
|
||||
Remove or use six.text_type().
|
||||
- [C315] Translated messages cannot be concatenated. String should be
|
||||
included in translated message.
|
||||
- [C317] `oslo_` should be used instead of `oslo.`
|
||||
|
@ -16,7 +16,6 @@
|
||||
from oslo_log import log as logging
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import six
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
@ -47,7 +46,7 @@ class MappingController(rest.RestController):
|
||||
return collector_models.ServiceToCollectorMapping(
|
||||
**mapping.as_dict())
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(collector_models.ServiceToCollectorMappingCollection,
|
||||
wtypes.text)
|
||||
@ -94,7 +93,7 @@ class MappingController(rest.RestController):
|
||||
try:
|
||||
self._db.delete_mapping(service)
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
|
||||
class CollectorStateController(rest.RestController):
|
||||
|
@ -17,7 +17,6 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import six
|
||||
import voluptuous
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -70,7 +69,7 @@ def get_one_metric(metric_name):
|
||||
policy.authorize(pecan.request.context, 'info:get_metric_info', {})
|
||||
metric = _find_metric(metric_name, metrics_conf)
|
||||
if not metric:
|
||||
pecan.abort(404, six.text_type(metric_name))
|
||||
pecan.abort(404, str(metric_name))
|
||||
info = metric.copy()
|
||||
info['metric_id'] = info['alt_name']
|
||||
return info_models.CloudkittyMetricInfo(**info)
|
||||
|
@ -15,11 +15,8 @@
|
||||
#
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseIOBackend(object):
|
||||
class BaseIOBackend(object, metaclass=abc.ABCMeta):
|
||||
def __init__(self, path):
|
||||
self.open(path)
|
||||
|
||||
|
@ -18,7 +18,6 @@ import fractions
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
from stevedore import driver
|
||||
from voluptuous import All
|
||||
from voluptuous import Any
|
||||
@ -153,8 +152,7 @@ class NoDataCollected(Exception):
|
||||
self.resource = resource
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseCollector(object):
|
||||
class BaseCollector(object, metaclass=abc.ABCMeta):
|
||||
collector_name = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -16,8 +16,6 @@
|
||||
from datetime import timedelta
|
||||
import requests
|
||||
|
||||
import six
|
||||
|
||||
from gnocchiclient import auth as gauth
|
||||
from gnocchiclient import client as gclient
|
||||
from gnocchiclient import exceptions as gexceptions
|
||||
@ -93,7 +91,7 @@ for agg in list(BASIC_AGGREGATION_METHODS):
|
||||
BASIC_AGGREGATION_METHODS.add("rate:%s" % agg)
|
||||
|
||||
EXTRA_AGGREGATION_METHODS_FOR_ARCHIVE_POLICY = set(
|
||||
(str(i) + 'pct' for i in six.moves.range(1, 100)))
|
||||
(str(i) + 'pct' for i in range(1, 100)))
|
||||
|
||||
for agg in list(EXTRA_AGGREGATION_METHODS_FOR_ARCHIVE_POLICY):
|
||||
EXTRA_AGGREGATION_METHODS_FOR_ARCHIVE_POLICY.add("rate:%s" % agg)
|
||||
@ -321,7 +319,7 @@ class GnocchiCollector(collector.BaseCollector):
|
||||
# FIXME(peschk_l): gnocchiclient seems to be raising a BadRequest
|
||||
# when it should be raising MetricNotFound
|
||||
if isinstance(e, gexceptions.BadRequest):
|
||||
if 'Metrics not found' not in six.text_type(e):
|
||||
if 'Metrics not found' not in e.args[0]:
|
||||
raise
|
||||
LOG.warning('[{scope}] Skipping this metric for the '
|
||||
'current cycle.'.format(scope=project_id, err=e))
|
||||
|
@ -23,7 +23,6 @@ from oslo_log import log as logging
|
||||
from oslo_policy import opts as policy_opts
|
||||
from oslo_policy import policy
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
|
||||
from cloudkitty.common import policies
|
||||
|
||||
@ -49,7 +48,7 @@ class PolicyNotAuthorized(Exception):
|
||||
super(PolicyNotAuthorized, self).__init__(self.msg)
|
||||
|
||||
def __unicode__(self):
|
||||
return six.text_type(self.msg)
|
||||
return str(self.msg)
|
||||
|
||||
|
||||
def reset():
|
||||
|
@ -17,7 +17,6 @@ import abc
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as db_api
|
||||
import six
|
||||
|
||||
_BACKEND_MAPPING = {'sqlalchemy': 'cloudkitty.db.sqlalchemy.api'}
|
||||
IMPL = db_api.DBAPI.from_config(cfg.CONF,
|
||||
@ -30,8 +29,7 @@ def get_instance():
|
||||
return IMPL
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class State(object):
|
||||
class State(object, metaclass=abc.ABCMeta):
|
||||
"""Base class for state tracking."""
|
||||
|
||||
@abc.abstractmethod
|
||||
@ -68,8 +66,7 @@ class State(object):
|
||||
"""
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ModuleInfo(object):
|
||||
class ModuleInfo(object, metaclass=abc.ABCMeta):
|
||||
"""Base class for module info management."""
|
||||
|
||||
@abc.abstractmethod
|
||||
@ -114,8 +111,7 @@ class NoSuchMapping(Exception):
|
||||
self.service = service
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ServiceToCollectorMapping(object):
|
||||
class ServiceToCollectorMapping(object, metaclass=abc.ABCMeta):
|
||||
"""Base class for service to collector mapping."""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import abc
|
||||
import six
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
@ -27,8 +26,7 @@ fetcher_opts = [
|
||||
cfg.CONF.register_opts(fetcher_opts, 'fetcher')
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseFetcher(object):
|
||||
class BaseFetcher(object, metaclass=abc.ABCMeta):
|
||||
"""CloudKitty tenants fetcher.
|
||||
|
||||
Provides Cloudkitty integration with a backend announcing ratable scopes.
|
||||
|
@ -17,7 +17,6 @@ import ast
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
import six
|
||||
|
||||
|
||||
"""
|
||||
@ -150,7 +149,7 @@ class CheckLoggingFormatArgs(BaseASTChecker):
|
||||
if obj_name is None:
|
||||
return None
|
||||
return obj_name + '.' + method_name
|
||||
elif isinstance(node, six.string_types):
|
||||
elif isinstance(node, str):
|
||||
return node
|
||||
else: # could be Subscript, Call or many more
|
||||
return None
|
||||
@ -221,7 +220,7 @@ class CheckForStrUnicodeExc(BaseASTChecker):
|
||||
version = "1.0"
|
||||
|
||||
CHECK_DESC = ('C314 str() and unicode() cannot be used on an '
|
||||
'exception. Remove or use six.text_type()')
|
||||
'exception. Remove it.')
|
||||
|
||||
def __init__(self, tree, filename):
|
||||
super(CheckForStrUnicodeExc, self).__init__(tree, filename)
|
||||
|
@ -17,15 +17,13 @@ import abc
|
||||
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import six
|
||||
|
||||
from cloudkitty.common import policy
|
||||
from cloudkitty.db import api as db_api
|
||||
from cloudkitty import messaging
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class RatingProcessorBase(object):
|
||||
class RatingProcessorBase(object, metaclass=abc.ABCMeta):
|
||||
"""Provides the Cloudkitty integration code to the rating processors.
|
||||
|
||||
Every rating processor should subclass this and override at least
|
||||
@ -142,6 +140,6 @@ class RatingRestControllerBase(rest.RestController):
|
||||
try:
|
||||
policy.authorize(request.context, 'rating:module_config', {})
|
||||
except policy.PolicyNotAuthorized as e:
|
||||
pecan.abort(403, six.text_type(e))
|
||||
pecan.abort(403, e.args[0])
|
||||
|
||||
return super(RatingRestControllerBase, self)._route(args, request)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from cloudkitty.api.v1 import types as ck_types
|
||||
@ -60,7 +59,7 @@ class HashMapFieldsController(rating.RatingRestControllerBase):
|
||||
field_db = hashmap.get_field(uuid=field_id)
|
||||
return field_models.Field(**field_db.export_model())
|
||||
except db_api.NoSuchField as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(field_models.Field,
|
||||
body=field_models.Field,
|
||||
@ -82,9 +81,9 @@ class HashMapFieldsController(rating.RatingRestControllerBase):
|
||||
return field_models.Field(
|
||||
**field_db.export_model())
|
||||
except db_api.FieldAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -98,4 +97,4 @@ class HashMapFieldsController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
hashmap.delete_field(uuid=field_id)
|
||||
except db_api.NoSuchField as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from cloudkitty.api.v1 import types as ck_types
|
||||
@ -95,7 +94,7 @@ class HashMapGroupsController(rating.RatingRestControllerBase):
|
||||
group_db = hashmap.get_group(uuid=group_id)
|
||||
return group_models.Group(**group_db.export_model())
|
||||
except db_api.NoSuchGroup as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(group_models.Group,
|
||||
body=group_models.Group,
|
||||
@ -115,9 +114,9 @@ class HashMapGroupsController(rating.RatingRestControllerBase):
|
||||
return group_models.Group(
|
||||
**group_db.export_model())
|
||||
except db_api.GroupAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -133,4 +132,4 @@ class HashMapGroupsController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
hashmap.delete_group(uuid=group_id, recurse=recursive)
|
||||
except db_api.NoSuchGroup as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from cloudkitty.api.v1 import types as ck_types
|
||||
@ -45,7 +44,7 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
uuid=mapping_id)
|
||||
return group_models.Group(**group_db.export_model())
|
||||
except db_api.MappingHasNoGroup as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(mapping_models.MappingCollection,
|
||||
ck_types.UuidType(),
|
||||
@ -105,7 +104,7 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
return mapping_models.Mapping(
|
||||
**mapping_db.export_model())
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(mapping_models.Mapping,
|
||||
body=mapping_models.Mapping,
|
||||
@ -132,9 +131,9 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
return mapping_models.Mapping(
|
||||
**mapping_db.export_model())
|
||||
except db_api.MappingAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -158,11 +157,11 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
tenant_id=mapping.tenant_id)
|
||||
pecan.response.headers['Location'] = pecan.request.path
|
||||
except db_api.MappingAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -176,4 +175,4 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
hashmap.delete_mapping(uuid=mapping_id)
|
||||
except db_api.NoSuchMapping as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from cloudkitty.api.v1 import types as ck_types
|
||||
@ -60,7 +59,7 @@ class HashMapServicesController(rating.RatingRestControllerBase):
|
||||
service_db = hashmap.get_service(uuid=service_id)
|
||||
return service_models.Service(**service_db.export_model())
|
||||
except db_api.NoSuchService as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(service_models.Service,
|
||||
body=service_models.Service,
|
||||
@ -80,7 +79,7 @@ class HashMapServicesController(rating.RatingRestControllerBase):
|
||||
return service_models.Service(
|
||||
**service_db.export_model())
|
||||
except db_api.ServiceAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None, ck_types.UuidType(), status_code=204)
|
||||
def delete(self, service_id):
|
||||
@ -92,4 +91,4 @@ class HashMapServicesController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
hashmap.delete_service(uuid=service_id)
|
||||
except db_api.NoSuchService as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from cloudkitty.api.v1 import types as ck_types
|
||||
@ -45,7 +44,7 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
uuid=threshold_id)
|
||||
return group_models.Group(**group_db.export_model())
|
||||
except db_api.ThresholdHasNoGroup as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(threshold_models.ThresholdCollection,
|
||||
ck_types.UuidType(),
|
||||
@ -104,7 +103,7 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
return threshold_models.Threshold(
|
||||
**threshold_db.export_model())
|
||||
except db_api.NoSuchThreshold as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(threshold_models.Threshold,
|
||||
body=threshold_models.Threshold,
|
||||
@ -131,9 +130,9 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
return threshold_models.Threshold(
|
||||
**threshold_db.export_model())
|
||||
except db_api.ThresholdAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -157,11 +156,11 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
tenant_id=threshold.tenant_id)
|
||||
pecan.response.headers['Location'] = pecan.request.path
|
||||
except db_api.ThresholdAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
except db_api.NoSuchThreshold as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
except db_api.ClientHashMapError as e:
|
||||
pecan.abort(400, six.text_type(e))
|
||||
pecan.abort(400, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None,
|
||||
ck_types.UuidType(),
|
||||
@ -175,4 +174,4 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
hashmap.delete_threshold(uuid=threshold_id)
|
||||
except db_api.NoSuchThreshold as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -17,7 +17,6 @@ import abc
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as db_api
|
||||
import six
|
||||
|
||||
from cloudkitty.i18n import _
|
||||
|
||||
@ -195,8 +194,7 @@ class ThresholdHasNoGroup(ClientHashMapError):
|
||||
self.uuid = uuid
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class HashMap(object):
|
||||
class HashMap(object, metaclass=abc.ABCMeta):
|
||||
"""Base class for hashmap configuration."""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -25,7 +25,6 @@ down_revision = '10d2738b67df'
|
||||
import copy # noqa: E402
|
||||
|
||||
from alembic import op # noqa: E402
|
||||
import six # noqa: E402
|
||||
|
||||
from cloudkitty.rating.hash.db.sqlalchemy.alembic.models import ( # noqa: E402
|
||||
f8c799db4aa0_fix_unnamed_constraints as models)
|
||||
@ -154,7 +153,7 @@ POST_OPS = {
|
||||
def upgrade_sqlite():
|
||||
# NOTE(sheeprine): Batch automatically recreates tables,
|
||||
# use it as a lazy way to recreate tables and transfer data automagically.
|
||||
for name, table in six.iteritems(models.Base.metadata.tables):
|
||||
for name, table in models.Base.metadata.tables.items():
|
||||
with op.batch_alter_table(name, copy_from=table) as batch_op:
|
||||
# NOTE(sheeprine): Dummy operation to force recreate.
|
||||
# Easier than delete and create.
|
||||
@ -168,13 +167,13 @@ def upgrade_mysql():
|
||||
tables['hashmap_fields'].constraints = set()
|
||||
tables['hashmap_mappings'].constraints = set()
|
||||
tables['hashmap_thresholds'].constraints = set()
|
||||
for name, table in six.iteritems(tables):
|
||||
for name, table in tables.items():
|
||||
with op.batch_alter_table(name,
|
||||
copy_from=table,
|
||||
recreate='always') as batch_op:
|
||||
batch_op.alter_column('id')
|
||||
# Final copy with constraints
|
||||
for name, table in six.iteritems(models.Base.metadata.tables):
|
||||
for name, table in models.Base.metadata.tables.items():
|
||||
with op.batch_alter_table(name,
|
||||
copy_from=table,
|
||||
recreate='always') as batch_op:
|
||||
@ -208,8 +207,8 @@ def upgrade_postgresql():
|
||||
ops_list = [POST_OPS]
|
||||
for cur_ops in ops_list:
|
||||
for constraint_type in ('foreignkey', 'unique', 'primary'):
|
||||
for table_name, constraints in six.iteritems(
|
||||
cur_ops.get(constraint_type, dict())):
|
||||
for table_name, constraints in cur_ops.get(constraint_type,
|
||||
dict()).items():
|
||||
for constraint in constraints:
|
||||
old_name = constraint[0]
|
||||
translate_op(
|
||||
@ -218,8 +217,8 @@ def upgrade_postgresql():
|
||||
old_name,
|
||||
table_name)
|
||||
for constraint_type in ('primary', 'unique', 'foreignkey'):
|
||||
for table_name, constraints in six.iteritems(
|
||||
cur_ops.get(constraint_type, dict())):
|
||||
for table_name, constraints in cur_ops.get(constraint_type,
|
||||
dict()).items():
|
||||
for constraint in constraints:
|
||||
new_name = constraint[1]
|
||||
params = constraint[2]
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
@ -36,7 +35,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
|
||||
"""
|
||||
if data == wtypes.Unset:
|
||||
return ''
|
||||
if not isinstance(data, six.binary_type):
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode('utf-8')
|
||||
return data
|
||||
|
||||
@ -71,7 +70,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
|
||||
script_db = pyscripts.get_script(uuid=script_id)
|
||||
return script_models.Script(**script_db.export_model())
|
||||
except db_api.NoSuchScript as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(script_models.Script,
|
||||
body=script_models.Script,
|
||||
@ -92,7 +91,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
|
||||
return script_models.Script(
|
||||
**script_db.export_model())
|
||||
except db_api.ScriptAlreadyExists as e:
|
||||
pecan.abort(409, six.text_type(e))
|
||||
pecan.abort(409, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(script_models.Script,
|
||||
ck_types.UuidType(),
|
||||
@ -117,7 +116,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
|
||||
return script_models.Script(
|
||||
**script_db.export_model())
|
||||
except db_api.NoSuchScript as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
||||
@wsme_pecan.wsexpose(None, ck_types.UuidType(), status_code=204)
|
||||
def delete(self, script_id):
|
||||
@ -129,4 +128,4 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
|
||||
try:
|
||||
pyscripts.delete_script(uuid=script_id)
|
||||
except db_api.NoSuchScript as e:
|
||||
pecan.abort(404, six.text_type(e))
|
||||
pecan.abort(404, e.args[0])
|
||||
|
@ -17,7 +17,6 @@ import abc
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as db_api
|
||||
import six
|
||||
|
||||
from cloudkitty.i18n import _
|
||||
|
||||
@ -55,8 +54,7 @@ class ScriptAlreadyExists(Exception):
|
||||
self.uuid = uuid
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PyScripts(object):
|
||||
class PyScripts(object, metaclass=abc.ABCMeta):
|
||||
"""Base class for pyscripts configuration."""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -18,16 +18,13 @@ from datetime import timedelta
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseStorage(object):
|
||||
class BaseStorage(object, metaclass=abc.ABCMeta):
|
||||
"""Base Storage class:
|
||||
|
||||
Handle incoming data from the global orchestrator, and store them.
|
||||
|
@ -15,11 +15,8 @@
|
||||
#
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseHybridBackend(object):
|
||||
class BaseHybridBackend(object, metaclass=abc.ABCMeta):
|
||||
"""Base Backend class for the Hybrid Storage.
|
||||
|
||||
This is the interface that all backends for the hybrid storage
|
||||
|
@ -22,7 +22,6 @@ from keystoneauth1 import loading as ks_loading
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from cloudkitty.collector import validate_conf
|
||||
from cloudkitty.storage.v1.hybrid.backends import BaseHybridBackend
|
||||
@ -47,7 +46,7 @@ gnocchi_storage_opts = [
|
||||
# The archive policy definition MUST include the collect period granularity
|
||||
cfg.StrOpt('archive_policy_definition',
|
||||
default='[{"granularity": '
|
||||
+ six.text_type(CONF.collect.period) +
|
||||
+ str(CONF.collect.period) +
|
||||
', "timespan": "90 days"}, '
|
||||
'{"granularity": 86400, "timespan": "360 days"}, '
|
||||
'{"granularity": 2592000, "timespan": "1800 days"}]',
|
||||
@ -398,7 +397,7 @@ class GnocchiStorage(BaseHybridBackend):
|
||||
price_dict = {'price': float(price)}
|
||||
|
||||
# Getting vol
|
||||
if isinstance(res_type_info['qty_metric'], six.string_types):
|
||||
if isinstance(res_type_info['qty_metric'], str):
|
||||
try:
|
||||
qty = self._conn.metric.get_measures(
|
||||
resource['metrics'][res_type_info['qty_metric']],
|
||||
|
@ -17,7 +17,6 @@ import abc
|
||||
import datetime
|
||||
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from cloudkitty import storage_state
|
||||
|
||||
@ -35,8 +34,7 @@ CONF = cfg.CONF
|
||||
CONF.register_opts(storage_opts, 'storage')
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseStorage(object):
|
||||
class BaseStorage(object, metaclass=abc.ABCMeta):
|
||||
"""Abstract class for v2 storage objects."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -13,11 +13,10 @@
|
||||
# under the License.
|
||||
#
|
||||
import datetime
|
||||
|
||||
import influxdb
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
from cloudkitty import dataframe
|
||||
from cloudkitty.storage import v2 as v2_storage
|
||||
@ -162,9 +161,9 @@ class InfluxClient(object):
|
||||
@staticmethod
|
||||
def _get_filter(key, value):
|
||||
format_string = ''
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
format_string = """"{}"='{}'"""
|
||||
elif isinstance(value, (six.integer_types, float)):
|
||||
elif isinstance(value, (int, float)):
|
||||
format_string = """"{}"={}"""
|
||||
return format_string.format(key, value)
|
||||
|
||||
|
@ -20,7 +20,6 @@ Create Date: 2019-05-15 17:02:56.595274
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import six
|
||||
|
||||
from cloudkitty.storage_state import models
|
||||
|
||||
@ -32,7 +31,7 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
for name, table in six.iteritems(models.Base.metadata.tables):
|
||||
for name, table in models.Base.metadata.tables.items():
|
||||
if name == 'cloudkitty_storage_states':
|
||||
|
||||
with op.batch_alter_table(name,
|
||||
|
@ -28,7 +28,6 @@ from oslo_db.sqlalchemy import utils
|
||||
import oslo_messaging
|
||||
from oslo_messaging import conffixture
|
||||
from oslo_policy import opts as policy_opts
|
||||
import six
|
||||
from stevedore import driver
|
||||
from stevedore import extension
|
||||
import webob.dec
|
||||
@ -70,8 +69,7 @@ class UUIDFixture(fixture.GabbiFixture):
|
||||
self.patcher.stop()
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseExtensionFixture(fixture.GabbiFixture):
|
||||
class BaseExtensionFixture(fixture.GabbiFixture, metaclass=abc.ABCMeta):
|
||||
klass = None
|
||||
namespace = None
|
||||
stevedore_mgr = None
|
||||
|
@ -20,7 +20,6 @@ from unittest import mock
|
||||
import zlib
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from cloudkitty.rating import pyscripts
|
||||
from cloudkitty.rating.pyscripts.db import api
|
||||
@ -220,7 +219,7 @@ class PyScriptsRatingTest(tests.TestCase):
|
||||
'<PyScripts Script[{uuid}]: name={name}>'.format(
|
||||
uuid=script_db.script_id,
|
||||
name=script_db.name),
|
||||
six.text_type(script_db))
|
||||
str(script_db))
|
||||
|
||||
# Checksum tests
|
||||
def test_validate_checksum(self):
|
||||
|
@ -17,9 +17,9 @@ import contextlib
|
||||
import datetime
|
||||
import decimal
|
||||
import fractions
|
||||
import importlib
|
||||
import math
|
||||
import shutil
|
||||
import six
|
||||
from string import Template
|
||||
import sys
|
||||
import tempfile
|
||||
@ -27,7 +27,6 @@ import yaml
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
from six import moves
|
||||
from stevedore import extension
|
||||
|
||||
from cloudkitty.utils import tz as tzutils
|
||||
@ -192,7 +191,7 @@ def refresh_stevedore(namespace=None):
|
||||
# python2, do nothing
|
||||
pass
|
||||
# Force working_set reload
|
||||
moves.reload_module(sys.modules['pkg_resources'])
|
||||
importlib.reload(sys.modules['pkg_resources'])
|
||||
# Clear stevedore cache
|
||||
cache = extension.ExtensionManager.ENTRY_POINT_CACHE
|
||||
if namespace:
|
||||
@ -249,8 +248,7 @@ def tempdir(**kwargs):
|
||||
try:
|
||||
shutil.rmtree(tmpdir)
|
||||
except OSError as e:
|
||||
LOG.debug('Could not remove tmpdir: %s',
|
||||
six.text_type(e))
|
||||
LOG.debug('Could not remove tmpdir: %s', e)
|
||||
|
||||
|
||||
def mutate(value, mode='NONE'):
|
||||
|
@ -18,9 +18,6 @@ try:
|
||||
except ImportError:
|
||||
from collections import Iterable
|
||||
import functools
|
||||
|
||||
import six
|
||||
|
||||
import voluptuous
|
||||
|
||||
|
||||
@ -95,4 +92,4 @@ class IterableValuesDict(DictTypeValidator):
|
||||
|
||||
def get_string_type():
|
||||
"""Returns ``basestring`` in python2 and ``str`` in python3."""
|
||||
return six.string_types[0]
|
||||
return str
|
||||
|
@ -15,14 +15,11 @@
|
||||
#
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from cloudkitty import state
|
||||
from cloudkitty import utils as ck_utils
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseReportWriter(object):
|
||||
class BaseReportWriter(object, metaclass=abc.ABCMeta):
|
||||
"""Base report writer."""
|
||||
report_type = None
|
||||
|
||||
|
@ -23,7 +23,6 @@ oslo.utils==4.7.0 # Apache-2.0
|
||||
oslo.upgradecheck==1.2.0 # Apache-2.0
|
||||
python-dateutil==2.7.0 # BSD
|
||||
SQLAlchemy==1.3.20 # MIT
|
||||
six==1.15.0 # MIT
|
||||
stevedore==3.2.2 # Apache-2.0
|
||||
tooz==2.7.1 # Apache-2.0
|
||||
voluptuous==0.12.0 # BSD-3
|
||||
|
@ -25,7 +25,6 @@ oslo.utils>=4.7.0 # Apache-2.0
|
||||
oslo.upgradecheck>=1.2.0 # Apache-2.0
|
||||
python-dateutil>=2.7.0 # BSD
|
||||
SQLAlchemy>=1.3.20 # MIT
|
||||
six>=1.15.0 # MIT
|
||||
stevedore>=3.2.2 # Apache-2.0
|
||||
tooz>=2.7.1 # Apache-2.0
|
||||
voluptuous>=0.12.0 # BSD License
|
||||
|
@ -19,7 +19,6 @@ oslo.middleware>=2.6.1 # Apache-2.0
|
||||
oslo.policy>=0.5.0 # Apache-2.0
|
||||
oslo.utils>=2.0.0 # Apache-2.0
|
||||
SQLAlchemy<1.1.0,>=0.9.7
|
||||
six>=1.9.0
|
||||
stevedore>=1.5.0 # Apache-2.0
|
||||
hacking<0.10,>=0.9.2
|
||||
coverage>=3.6
|
||||
|
Loading…
Reference in New Issue
Block a user