From 7ef90aeccfc421a292cdbeaa06f2a9c7129b8d97 Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Singh Date: Tue, 30 Jun 2015 09:39:44 +0530 Subject: [PATCH] Replace dict.iteritems() with dict.items() Partially-Implements: blueprint designate-py3 Change-Id: I068d05e77bd94cbe2ce613dd4428545144214786 --- designate/api/admin/controllers/extensions/quotas.py | 2 +- designate/backend/agent_backend/impl_denominator.py | 4 ++-- designate/objects/adapters/api_v2/pool_attribute.py | 2 +- designate/objects/adapters/api_v2/validation_error.py | 2 +- designate/objects/adapters/base.py | 4 ++-- designate/objects/base.py | 4 ++-- designate/sqlalchemy/base.py | 6 +++--- designate/sqlalchemy/session.py | 2 +- designate/tests/__init__.py | 2 +- designate/tests/test_central/_test_service_ipa.py | 4 ++-- designate/utils.py | 2 +- functionaltests/common/models.py | 2 +- functionaltests/common/utils.py | 6 +++--- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/designate/api/admin/controllers/extensions/quotas.py b/designate/api/admin/controllers/extensions/quotas.py index d7427d5b2..c97b28b7e 100644 --- a/designate/api/admin/controllers/extensions/quotas.py +++ b/designate/api/admin/controllers/extensions/quotas.py @@ -53,7 +53,7 @@ class QuotasController(rest.RestController): values = self._view.load(context, request, body) - for resource, hard_limit in values.iteritems(): + for resource, hard_limit in values.items(): self.central_api.set_quota(context, tenant_id, resource, hard_limit) diff --git a/designate/backend/agent_backend/impl_denominator.py b/designate/backend/agent_backend/impl_denominator.py index 64e7d1172..1b92b0f6a 100644 --- a/designate/backend/agent_backend/impl_denominator.py +++ b/designate/backend/agent_backend/impl_denominator.py @@ -63,7 +63,7 @@ class Denominator(object): return self._execute(['zone', 'delete'], kwargs) def _params(self, **kwargs): - params = [('--%s' % k, str(v)) for k, v in kwargs.iteritems()] + params = [('--%s' % k, str(v)) for k, v in kwargs.items()] return list(itertools.chain(*params)) def _base(self): @@ -219,7 +219,7 @@ class DenominatorBackend(base.AgentBackend): data=data) # Remaining records should be deleted - for name, types in subdomains.iteritems(): + for name, types in subdomains.items(): for rtype in types: self.denominator.delete_record( zone=domain_name, id=name, type=rtype) diff --git a/designate/objects/adapters/api_v2/pool_attribute.py b/designate/objects/adapters/api_v2/pool_attribute.py index e8967de16..f8279f4a2 100644 --- a/designate/objects/adapters/api_v2/pool_attribute.py +++ b/designate/objects/adapters/api_v2/pool_attribute.py @@ -80,7 +80,7 @@ class PoolAttributeListAPIv2Adapter(base.APIv2Adapter): @classmethod def _parse_list(cls, values, output_object, *args, **kwargs): - for key, value in values.iteritems(): + for key, value in values.items(): # Add the object to the list output_object.append( # Get the right Adapter diff --git a/designate/objects/adapters/api_v2/validation_error.py b/designate/objects/adapters/api_v2/validation_error.py index 9ac2c8554..7ec292e4a 100644 --- a/designate/objects/adapters/api_v2/validation_error.py +++ b/designate/objects/adapters/api_v2/validation_error.py @@ -90,7 +90,7 @@ class ValidationErrorAPIv2Adapter(base.APIv2Adapter): return path_segment, obj_adapter for key, value in obj_adapter.MODIFICATIONS.get( - 'fields', {}).iteritems(): + 'fields', {}).items(): # Check if this field as actually a nested object if object.FIELDS.get(path_segment, {}).get('relation', False): diff --git a/designate/objects/adapters/base.py b/designate/objects/adapters/base.py index 145ead6f1..d42bcfa19 100644 --- a/designate/objects/adapters/base.py +++ b/designate/objects/adapters/base.py @@ -92,7 +92,7 @@ class DesignateAdapter(object): # The dict we will return to be rendered to JSON / output format r_obj = {} # Loop over all fields that are supposed to be output - for key, value in cls.MODIFICATIONS['fields'].iteritems(): + for key, value in cls.MODIFICATIONS['fields'].items(): # Get properties for this field field_props = cls.MODIFICATIONS['fields'][key] # Check if it has to be renamed @@ -156,7 +156,7 @@ class DesignateAdapter(object): def _parse_object(cls, values, output_object, *args, **kwargs): error_keys = [] - for key, value in values.iteritems(): + for key, value in values.items(): if key in cls.MODIFICATIONS['fields']: # No rename needed obj_key = key diff --git a/designate/objects/base.py b/designate/objects/base.py index 74b284f14..bc83bb91a 100644 --- a/designate/objects/base.py +++ b/designate/objects/base.py @@ -274,7 +274,7 @@ class DesignateObject(object): def update(self, values): """Update a object's fields with the supplied key/value pairs""" - for k, v in values.iteritems(): + for k, v in values.items(): setattr(self, k, v) @property @@ -430,7 +430,7 @@ class DictObjectMixin(object): if self.obj_attr_is_set(field): yield field, getattr(self, field) - items = lambda self: list(self.iteritems()) + items = lambda self: list(self.items()) class ListObjectMixin(object): diff --git a/designate/sqlalchemy/base.py b/designate/sqlalchemy/base.py index 820d985f2..da23b3202 100644 --- a/designate/sqlalchemy/base.py +++ b/designate/sqlalchemy/base.py @@ -412,7 +412,7 @@ class SQLAlchemy(object): # Add all the loaded vars into RecordSet object - for key, value in rs_map.iteritems(): + for key, value in rs_map.items(): setattr(current_rrset, key, record[value]) current_rrset.records = relation_list_cls() @@ -420,7 +420,7 @@ class SQLAlchemy(object): if record[r_map['id']] is not None: rrdata = relation_cls() - for key, value in r_map.iteritems(): + for key, value in r_map.items(): setattr(rrdata, key, record[value]) current_rrset.records.append(rrdata) @@ -429,7 +429,7 @@ class SQLAlchemy(object): # We've already got an rrset, add the rdata if record[r_map['id']] is not None: - for key, value in r_map.iteritems(): + for key, value in r_map.items(): setattr(rrdata, key, record[value]) current_rrset.records.append(rrdata) diff --git a/designate/sqlalchemy/session.py b/designate/sqlalchemy/session.py index 49729f57d..093593ef7 100644 --- a/designate/sqlalchemy/session.py +++ b/designate/sqlalchemy/session.py @@ -36,7 +36,7 @@ def _create_facade_lazily(cfg_group, connection=None, discriminator=None): if cache_name not in _FACADES: _FACADES[cache_name] = session.EngineFacade( connection, - **dict(cfg.CONF[cfg_group].iteritems())) + **dict(cfg.CONF[cfg_group].items())) return _FACADES[cache_name] diff --git a/designate/tests/__init__.py b/designate/tests/__init__.py index f284539ad..d5f9f228a 100644 --- a/designate/tests/__init__.py +++ b/designate/tests/__init__.py @@ -360,7 +360,7 @@ class TestCase(base.BaseTestCase): def config(self, **kwargs): group = kwargs.pop('group', None) - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): cfg.CONF.set_override(k, v, group) def policy(self, rules, default_rule='allow', overwrite=True): diff --git a/designate/tests/test_central/_test_service_ipa.py b/designate/tests/test_central/_test_service_ipa.py index f2d9beaca..458ff7bb3 100644 --- a/designate/tests/test_central/_test_service_ipa.py +++ b/designate/tests/test_central/_test_service_ipa.py @@ -77,8 +77,8 @@ class CentralServiceTestIPA(designate.tests.test_central. super(CentralServiceTestIPA, self).tearDown() def assertRecordsEqual(self, rec1, rec2): - rec1dict = dict(rec1.iteritems()) - rec2dict = dict(rec2.iteritems()) + rec1dict = dict(rec1.items()) + rec2dict = dict(rec2.items()) self.assertEqual(rec1dict, rec2dict) def test_delete_recordset_extra(self): diff --git a/designate/utils.py b/designate/utils.py index 3f644e120..72fe6eb1a 100644 --- a/designate/utils.py +++ b/designate/utils.py @@ -271,7 +271,7 @@ def deep_dict_merge(a, b): result = copy.deepcopy(a) - for k, v in b.iteritems(): + for k, v in b.items(): if k in result and isinstance(result[k], dict): result[k] = deep_dict_merge(result[k], v) else: diff --git a/functionaltests/common/models.py b/functionaltests/common/models.py index af2757e7e..b012c9f96 100644 --- a/functionaltests/common/models.py +++ b/functionaltests/common/models.py @@ -79,7 +79,7 @@ class CollectionModel(BaseModel): setattr(model, cls.COLLECTION_NAME, collection) # deserialize data[' - for key, model_type in cls.SUB_MODELS.iteritems(): + for key, model_type in cls.SUB_MODELS.items(): if hasattr(model, key): val = getattr(model, key) setattr(model, key, model_type.from_dict(val)) diff --git a/functionaltests/common/utils.py b/functionaltests/common/utils.py index 80dc59a80..8fbb8fcaf 100644 --- a/functionaltests/common/utils.py +++ b/functionaltests/common/utils.py @@ -33,9 +33,9 @@ def parameterized_class(cls): Mark your test cases with @parameterized. """ test_functions = { - k: v for k, v in vars(cls).iteritems() if k.startswith('test') + k: v for k, v in vars(cls).items() if k.startswith('test') } - for name, f in test_functions.iteritems(): + for name, f in test_functions.items(): if not hasattr(f, '_test_data'): continue @@ -43,7 +43,7 @@ def parameterized_class(cls): delattr(cls, name) # add a new test function to the class for each entry in f._test_data - for tag, args in f._test_data.iteritems(): + for tag, args in f._test_data.items(): new_name = "{0}_{1}".format(f.__name__, tag) if hasattr(cls, new_name): raise Exception(