Merge "Replace six.iteritems() with .items()"
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
#
|
||||
import decimal
|
||||
|
||||
import six
|
||||
|
||||
from cloudkitty import rating
|
||||
from cloudkitty.rating.hash.controllers import root as root_api
|
||||
from cloudkitty.rating.hash.db import api as hash_db_api
|
||||
@@ -107,7 +105,7 @@ class HashMap(rating.RatingProcessorBase):
|
||||
entries = load_func(entries_uuid_list)
|
||||
if entry_type in root:
|
||||
res = root[entry_type]
|
||||
for group, values in six.iteritems(entries):
|
||||
for group, values in entries.items():
|
||||
if group in res:
|
||||
res[group].update(values)
|
||||
else:
|
||||
|
||||
@@ -24,7 +24,6 @@ revision = '4da82e1c11c8'
|
||||
down_revision = 'c88a06b1cfce'
|
||||
|
||||
from alembic import op
|
||||
import six
|
||||
import sqlalchemy as sa
|
||||
|
||||
CONSTRAINT_MAP = {
|
||||
@@ -92,6 +91,6 @@ def upgrade():
|
||||
'tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=True))
|
||||
for name, columns in six.iteritems(CONSTRAINT_MAP[table]):
|
||||
for name, columns in CONSTRAINT_MAP[table].items():
|
||||
batch_op.drop_constraint(name, type_='unique')
|
||||
batch_op.create_unique_constraint(name, columns[0])
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
from oslo_db import exception
|
||||
from oslo_db.sqlalchemy import utils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import sqlalchemy
|
||||
|
||||
from cloudkitty import db
|
||||
@@ -423,7 +422,7 @@ class HashMap(api.HashMap):
|
||||
for col in excluded_cols:
|
||||
if col in kwargs:
|
||||
kwargs.pop(col)
|
||||
for attribute, value in six.iteritems(kwargs):
|
||||
for attribute, value in kwargs.items():
|
||||
if hasattr(mapping_db, attribute):
|
||||
setattr(mapping_db, attribute, value)
|
||||
else:
|
||||
@@ -456,7 +455,7 @@ class HashMap(api.HashMap):
|
||||
for col in excluded_cols:
|
||||
if col in kwargs:
|
||||
kwargs.pop(col)
|
||||
for attribute, value in six.iteritems(kwargs):
|
||||
for attribute, value in kwargs.items():
|
||||
if hasattr(threshold_db, attribute):
|
||||
setattr(threshold_db, attribute, value)
|
||||
else:
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
from oslo_db import exception
|
||||
from oslo_db.sqlalchemy import utils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import sqlalchemy
|
||||
|
||||
from cloudkitty import db
|
||||
@@ -89,7 +88,7 @@ class PyScripts(api.PyScripts):
|
||||
for col in excluded_cols:
|
||||
if col in kwargs:
|
||||
kwargs.pop(col)
|
||||
for attribute, value in six.iteritems(kwargs):
|
||||
for attribute, value in kwargs.items():
|
||||
if hasattr(script_db, attribute):
|
||||
setattr(script_db, attribute, value)
|
||||
else:
|
||||
|
||||
@@ -155,7 +155,7 @@ class GnocchiStorage(storage.BaseStorage):
|
||||
def _pre_commit(self, tenant_id):
|
||||
measures = self._measures.pop(tenant_id, {})
|
||||
self._measures[tenant_id] = dict()
|
||||
for resource_id, metrics in six.iteritems(measures):
|
||||
for resource_id, metrics in measures.items():
|
||||
total = metrics.pop('total.cost')
|
||||
total_id = self._get_or_create_metric(
|
||||
'total.cost',
|
||||
@@ -167,7 +167,7 @@ class GnocchiStorage(storage.BaseStorage):
|
||||
self._measures[tenant_id][total_id] = [{
|
||||
'timestamp': total_timestamp.isoformat(),
|
||||
'value': six.text_type(total_value)}]
|
||||
for metric_name, values in six.iteritems(metrics):
|
||||
for metric_name, values in metrics.items():
|
||||
metric_id = self._get_or_create_metric(
|
||||
metric_name,
|
||||
resource_id)
|
||||
@@ -205,7 +205,7 @@ class GnocchiStorage(storage.BaseStorage):
|
||||
metrics[metric_name] = [sample]
|
||||
|
||||
def _dispatch(self, data, tenant_id):
|
||||
for metric_name, metrics in six.iteritems(data):
|
||||
for metric_name, metrics in data.items():
|
||||
for item in metrics:
|
||||
resource_id = item["desc"]["resource_id"]
|
||||
price = item["rating"]["price"]
|
||||
|
||||
@@ -21,7 +21,6 @@ from keystoneclient import client as kclient
|
||||
from keystoneclient import discover
|
||||
from keystoneclient import exceptions
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from cloudkitty import tenant_fetcher
|
||||
|
||||
@@ -62,7 +61,7 @@ class KeystoneFetcher(tenant_fetcher.BaseFetcher):
|
||||
CONF.keystone_fetcher.keystone_version)
|
||||
auth_dispatch = {(3,): ('project', 'projects', 'list'),
|
||||
(2,): ('tenant', 'tenants', 'roles_for_user')}
|
||||
for auth_version, auth_version_mapping in six.iteritems(auth_dispatch):
|
||||
for auth_version, auth_version_mapping in auth_dispatch.items():
|
||||
if discover.version_match(auth_version, keystone_version):
|
||||
return self._do_get_tenants(auth_version_mapping)
|
||||
msg = "Keystone version you've specified is not supported"
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
import copy
|
||||
import decimal
|
||||
|
||||
import six
|
||||
|
||||
from cloudkitty import utils as ck_utils
|
||||
|
||||
TENANT = 'f266f30b11f246b589fd266f85eeec39'
|
||||
@@ -110,7 +108,7 @@ def split_storage_data(raw_data):
|
||||
frame['period']['end'] = ck_utils.ts2iso(frame['period']['end'])
|
||||
usage_buffer = frame.pop('usage')
|
||||
# Sort to have a consistent result as we are converting it to a list
|
||||
for service, data in sorted(six.iteritems(usage_buffer)):
|
||||
for service, data in sorted(usage_buffer.items()):
|
||||
new_frame = copy.deepcopy(frame)
|
||||
new_frame['usage'] = {service: data}
|
||||
new_frame['usage'][service][0]['tenant_id'] = TENANT
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import copy
|
||||
|
||||
import mock
|
||||
import six
|
||||
import sqlalchemy
|
||||
import testscenarios
|
||||
|
||||
@@ -120,7 +119,7 @@ class StorageTest(tests.TestCase):
|
||||
def test_send_nodata_between_data(self):
|
||||
working_data = copy.deepcopy(samples.RATED_DATA)
|
||||
for period in working_data:
|
||||
for service, data in sorted(six.iteritems(period['usage'])):
|
||||
for service, data in sorted(period['usage'].items()):
|
||||
sub_data = [{
|
||||
'period': period['period'],
|
||||
'usage': {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#
|
||||
# @author: Stéphane Albert
|
||||
#
|
||||
import six
|
||||
|
||||
from cloudkitty.tests import samples
|
||||
from cloudkitty import transformer
|
||||
|
||||
@@ -54,5 +52,5 @@ class EmptyClass(object):
|
||||
|
||||
class ClassWithAttr(object):
|
||||
def __init__(self, items=samples.COMPUTE_METADATA):
|
||||
for key, val in six.iteritems(items):
|
||||
for key, val in items.items():
|
||||
setattr(self, key, val)
|
||||
|
||||
@@ -43,7 +43,7 @@ class BaseTransformer(object):
|
||||
metadata = getattr(data, self.metadata_item, data)
|
||||
mappings = getattr(self, datatype + '_map', {})
|
||||
result = {}
|
||||
for key, transform in six.iteritems(mappings):
|
||||
for key, transform in mappings.items():
|
||||
if isinstance(transform, list):
|
||||
for meta_key in transform:
|
||||
if key not in result or result[key] is None:
|
||||
|
||||
Reference in New Issue
Block a user