Replace dict.iteritems() with dict.items()
Partially-Implements: blueprint designate-py3 Change-Id: I068d05e77bd94cbe2ce613dd4428545144214786
This commit is contained in:
parent
77783cb377
commit
7ef90aeccf
@ -53,7 +53,7 @@ class QuotasController(rest.RestController):
|
|||||||
|
|
||||||
values = self._view.load(context, request, body)
|
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,
|
self.central_api.set_quota(context, tenant_id, resource,
|
||||||
hard_limit)
|
hard_limit)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class Denominator(object):
|
|||||||
return self._execute(['zone', 'delete'], kwargs)
|
return self._execute(['zone', 'delete'], kwargs)
|
||||||
|
|
||||||
def _params(self, **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))
|
return list(itertools.chain(*params))
|
||||||
|
|
||||||
def _base(self):
|
def _base(self):
|
||||||
@ -219,7 +219,7 @@ class DenominatorBackend(base.AgentBackend):
|
|||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
# Remaining records should be deleted
|
# Remaining records should be deleted
|
||||||
for name, types in subdomains.iteritems():
|
for name, types in subdomains.items():
|
||||||
for rtype in types:
|
for rtype in types:
|
||||||
self.denominator.delete_record(
|
self.denominator.delete_record(
|
||||||
zone=domain_name, id=name, type=rtype)
|
zone=domain_name, id=name, type=rtype)
|
||||||
|
@ -80,7 +80,7 @@ class PoolAttributeListAPIv2Adapter(base.APIv2Adapter):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _parse_list(cls, values, output_object, *args, **kwargs):
|
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
|
# Add the object to the list
|
||||||
output_object.append(
|
output_object.append(
|
||||||
# Get the right Adapter
|
# Get the right Adapter
|
||||||
|
@ -90,7 +90,7 @@ class ValidationErrorAPIv2Adapter(base.APIv2Adapter):
|
|||||||
return path_segment, obj_adapter
|
return path_segment, obj_adapter
|
||||||
|
|
||||||
for key, value in obj_adapter.MODIFICATIONS.get(
|
for key, value in obj_adapter.MODIFICATIONS.get(
|
||||||
'fields', {}).iteritems():
|
'fields', {}).items():
|
||||||
|
|
||||||
# Check if this field as actually a nested object
|
# Check if this field as actually a nested object
|
||||||
if object.FIELDS.get(path_segment, {}).get('relation', False):
|
if object.FIELDS.get(path_segment, {}).get('relation', False):
|
||||||
|
@ -92,7 +92,7 @@ class DesignateAdapter(object):
|
|||||||
# The dict we will return to be rendered to JSON / output format
|
# The dict we will return to be rendered to JSON / output format
|
||||||
r_obj = {}
|
r_obj = {}
|
||||||
# Loop over all fields that are supposed to be output
|
# 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
|
# Get properties for this field
|
||||||
field_props = cls.MODIFICATIONS['fields'][key]
|
field_props = cls.MODIFICATIONS['fields'][key]
|
||||||
# Check if it has to be renamed
|
# Check if it has to be renamed
|
||||||
@ -156,7 +156,7 @@ class DesignateAdapter(object):
|
|||||||
def _parse_object(cls, values, output_object, *args, **kwargs):
|
def _parse_object(cls, values, output_object, *args, **kwargs):
|
||||||
error_keys = []
|
error_keys = []
|
||||||
|
|
||||||
for key, value in values.iteritems():
|
for key, value in values.items():
|
||||||
if key in cls.MODIFICATIONS['fields']:
|
if key in cls.MODIFICATIONS['fields']:
|
||||||
# No rename needed
|
# No rename needed
|
||||||
obj_key = key
|
obj_key = key
|
||||||
|
@ -274,7 +274,7 @@ class DesignateObject(object):
|
|||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Update a object's fields with the supplied key/value pairs"""
|
"""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)
|
setattr(self, k, v)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -430,7 +430,7 @@ class DictObjectMixin(object):
|
|||||||
if self.obj_attr_is_set(field):
|
if self.obj_attr_is_set(field):
|
||||||
yield field, getattr(self, field)
|
yield field, getattr(self, field)
|
||||||
|
|
||||||
items = lambda self: list(self.iteritems())
|
items = lambda self: list(self.items())
|
||||||
|
|
||||||
|
|
||||||
class ListObjectMixin(object):
|
class ListObjectMixin(object):
|
||||||
|
@ -412,7 +412,7 @@ class SQLAlchemy(object):
|
|||||||
|
|
||||||
# Add all the loaded vars into RecordSet 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])
|
setattr(current_rrset, key, record[value])
|
||||||
|
|
||||||
current_rrset.records = relation_list_cls()
|
current_rrset.records = relation_list_cls()
|
||||||
@ -420,7 +420,7 @@ class SQLAlchemy(object):
|
|||||||
if record[r_map['id']] is not None:
|
if record[r_map['id']] is not None:
|
||||||
rrdata = relation_cls()
|
rrdata = relation_cls()
|
||||||
|
|
||||||
for key, value in r_map.iteritems():
|
for key, value in r_map.items():
|
||||||
setattr(rrdata, key, record[value])
|
setattr(rrdata, key, record[value])
|
||||||
|
|
||||||
current_rrset.records.append(rrdata)
|
current_rrset.records.append(rrdata)
|
||||||
@ -429,7 +429,7 @@ class SQLAlchemy(object):
|
|||||||
# We've already got an rrset, add the rdata
|
# We've already got an rrset, add the rdata
|
||||||
if record[r_map['id']] is not None:
|
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])
|
setattr(rrdata, key, record[value])
|
||||||
|
|
||||||
current_rrset.records.append(rrdata)
|
current_rrset.records.append(rrdata)
|
||||||
|
@ -36,7 +36,7 @@ def _create_facade_lazily(cfg_group, connection=None, discriminator=None):
|
|||||||
if cache_name not in _FACADES:
|
if cache_name not in _FACADES:
|
||||||
_FACADES[cache_name] = session.EngineFacade(
|
_FACADES[cache_name] = session.EngineFacade(
|
||||||
connection,
|
connection,
|
||||||
**dict(cfg.CONF[cfg_group].iteritems()))
|
**dict(cfg.CONF[cfg_group].items()))
|
||||||
|
|
||||||
return _FACADES[cache_name]
|
return _FACADES[cache_name]
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ class TestCase(base.BaseTestCase):
|
|||||||
def config(self, **kwargs):
|
def config(self, **kwargs):
|
||||||
group = kwargs.pop('group', None)
|
group = kwargs.pop('group', None)
|
||||||
|
|
||||||
for k, v in kwargs.iteritems():
|
for k, v in kwargs.items():
|
||||||
cfg.CONF.set_override(k, v, group)
|
cfg.CONF.set_override(k, v, group)
|
||||||
|
|
||||||
def policy(self, rules, default_rule='allow', overwrite=True):
|
def policy(self, rules, default_rule='allow', overwrite=True):
|
||||||
|
@ -77,8 +77,8 @@ class CentralServiceTestIPA(designate.tests.test_central.
|
|||||||
super(CentralServiceTestIPA, self).tearDown()
|
super(CentralServiceTestIPA, self).tearDown()
|
||||||
|
|
||||||
def assertRecordsEqual(self, rec1, rec2):
|
def assertRecordsEqual(self, rec1, rec2):
|
||||||
rec1dict = dict(rec1.iteritems())
|
rec1dict = dict(rec1.items())
|
||||||
rec2dict = dict(rec2.iteritems())
|
rec2dict = dict(rec2.items())
|
||||||
self.assertEqual(rec1dict, rec2dict)
|
self.assertEqual(rec1dict, rec2dict)
|
||||||
|
|
||||||
def test_delete_recordset_extra(self):
|
def test_delete_recordset_extra(self):
|
||||||
|
@ -271,7 +271,7 @@ def deep_dict_merge(a, b):
|
|||||||
|
|
||||||
result = copy.deepcopy(a)
|
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):
|
if k in result and isinstance(result[k], dict):
|
||||||
result[k] = deep_dict_merge(result[k], v)
|
result[k] = deep_dict_merge(result[k], v)
|
||||||
else:
|
else:
|
||||||
|
@ -79,7 +79,7 @@ class CollectionModel(BaseModel):
|
|||||||
setattr(model, cls.COLLECTION_NAME, collection)
|
setattr(model, cls.COLLECTION_NAME, collection)
|
||||||
|
|
||||||
# deserialize data['
|
# deserialize data['
|
||||||
for key, model_type in cls.SUB_MODELS.iteritems():
|
for key, model_type in cls.SUB_MODELS.items():
|
||||||
if hasattr(model, key):
|
if hasattr(model, key):
|
||||||
val = getattr(model, key)
|
val = getattr(model, key)
|
||||||
setattr(model, key, model_type.from_dict(val))
|
setattr(model, key, model_type.from_dict(val))
|
||||||
|
@ -33,9 +33,9 @@ def parameterized_class(cls):
|
|||||||
Mark your test cases with @parameterized.
|
Mark your test cases with @parameterized.
|
||||||
"""
|
"""
|
||||||
test_functions = {
|
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'):
|
if not hasattr(f, '_test_data'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ def parameterized_class(cls):
|
|||||||
delattr(cls, name)
|
delattr(cls, name)
|
||||||
|
|
||||||
# add a new test function to the class for each entry in f._test_data
|
# 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)
|
new_name = "{0}_{1}".format(f.__name__, tag)
|
||||||
if hasattr(cls, new_name):
|
if hasattr(cls, new_name):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
Loading…
Reference in New Issue
Block a user