Merge "Python3: Add support for iteritems and iterkeys"
This commit is contained in:
commit
40110dbf32
@ -210,7 +210,7 @@ class Debug(Middleware):
|
|||||||
resp = req.get_response(self.application)
|
resp = req.get_response(self.application)
|
||||||
|
|
||||||
print(("*" * 40) + " RESPONSE HEADERS")
|
print(("*" * 40) + " RESPONSE HEADERS")
|
||||||
for (key, value) in resp.headers.iteritems():
|
for (key, value) in resp.headers.items():
|
||||||
print(key, "=", value)
|
print(key, "=", value)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class ActionExtensionController(object):
|
|||||||
self.action_handlers[action_name] = handler
|
self.action_handlers[action_name] = handler
|
||||||
|
|
||||||
def action(self, req, id, body):
|
def action(self, req, id, body):
|
||||||
for action_name, handler in self.action_handlers.iteritems():
|
for action_name, handler in self.action_handlers.items():
|
||||||
if action_name in body:
|
if action_name in body:
|
||||||
return handler(body, req, id)
|
return handler(body, req, id)
|
||||||
# no action handler found (bump to downstream application)
|
# no action handler found (bump to downstream application)
|
||||||
@ -191,7 +191,7 @@ class ExtensionsResource(wsgi.Resource):
|
|||||||
|
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
extensions = []
|
extensions = []
|
||||||
for _alias, ext in self.extension_manager.extensions.iteritems():
|
for _alias, ext in self.extension_manager.extensions.items():
|
||||||
extensions.append(self._translate(ext))
|
extensions.append(self._translate(ext))
|
||||||
return dict(extensions=extensions)
|
return dict(extensions=extensions)
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||||||
|
|
||||||
def _map_custom_collection_actions(self, resource_ext, mapper,
|
def _map_custom_collection_actions(self, resource_ext, mapper,
|
||||||
controller_resource):
|
controller_resource):
|
||||||
for action, method in resource_ext.collection_actions.iteritems():
|
for action, method in resource_ext.collection_actions.items():
|
||||||
parent = resource_ext.parent
|
parent = resource_ext.parent
|
||||||
conditions = dict(method=[method])
|
conditions = dict(method=[method])
|
||||||
path = "/%s/%s" % (resource_ext.collection, action)
|
path = "/%s/%s" % (resource_ext.collection, action)
|
||||||
@ -362,7 +362,7 @@ class ExtensionManager(object):
|
|||||||
extension_resource,
|
extension_resource,
|
||||||
serializer=extension_resource.serializer)
|
serializer=extension_resource.serializer)
|
||||||
resources.append(res_ext)
|
resources.append(res_ext)
|
||||||
for alias, ext in self.extensions.iteritems():
|
for alias, ext in self.extensions.items():
|
||||||
try:
|
try:
|
||||||
resources.extend(ext.get_resources())
|
resources.extend(ext.get_resources())
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -372,7 +372,7 @@ class ExtensionManager(object):
|
|||||||
def get_actions(self):
|
def get_actions(self):
|
||||||
"""Returns a list of ActionExtension objects."""
|
"""Returns a list of ActionExtension objects."""
|
||||||
actions = []
|
actions = []
|
||||||
for alias, ext in self.extensions.iteritems():
|
for alias, ext in self.extensions.items():
|
||||||
try:
|
try:
|
||||||
actions.extend(ext.get_actions())
|
actions.extend(ext.get_actions())
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -382,7 +382,7 @@ class ExtensionManager(object):
|
|||||||
def get_request_extensions(self):
|
def get_request_extensions(self):
|
||||||
"""Returns a list of RequestExtension objects."""
|
"""Returns a list of RequestExtension objects."""
|
||||||
request_exts = []
|
request_exts = []
|
||||||
for alias, ext in self.extensions.iteritems():
|
for alias, ext in self.extensions.items():
|
||||||
try:
|
try:
|
||||||
request_exts.extend(ext.get_request_extensions())
|
request_exts.extend(ext.get_request_extensions())
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -218,7 +218,7 @@ class SwiftStorage(base.Storage):
|
|||||||
self._verify_checksum(headers.get('etag', ''), backup_checksum)
|
self._verify_checksum(headers.get('etag', ''), backup_checksum)
|
||||||
|
|
||||||
_meta = {}
|
_meta = {}
|
||||||
for key, value in headers.iteritems():
|
for key, value in headers.items():
|
||||||
if key.startswith('x-object-meta'):
|
if key.startswith('x-object-meta'):
|
||||||
_meta[self._get_attr(key)] = value
|
_meta[self._get_attr(key)] = value
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ class SwiftStorage(base.Storage):
|
|||||||
|
|
||||||
_headers = self.connection.head_object(container, filename)
|
_headers = self.connection.head_object(container, filename)
|
||||||
headers = {'X-Object-Manifest': _headers.get('x-object-manifest')}
|
headers = {'X-Object-Manifest': _headers.get('x-object-manifest')}
|
||||||
for key, value in metadata.iteritems():
|
for key, value in metadata.items():
|
||||||
headers[self._set_attr(key)] = value
|
headers[self._set_attr(key)] = value
|
||||||
|
|
||||||
LOG.info(_("Writing metadata: %s"), str(headers))
|
LOG.info(_("Writing metadata: %s"), str(headers))
|
||||||
|
@ -83,13 +83,13 @@ def create_method_args_string(*args, **kwargs):
|
|||||||
def stringify_keys(dictionary):
|
def stringify_keys(dictionary):
|
||||||
if dictionary is None:
|
if dictionary is None:
|
||||||
return None
|
return None
|
||||||
return {str(key): value for key, value in dictionary.iteritems()}
|
return {str(key): value for key, value in dictionary.items()}
|
||||||
|
|
||||||
|
|
||||||
def exclude(key_values, *exclude_keys):
|
def exclude(key_values, *exclude_keys):
|
||||||
if key_values is None:
|
if key_values is None:
|
||||||
return None
|
return None
|
||||||
return {key: value for key, value in key_values.iteritems()
|
return {key: value for key, value in key_values.items()
|
||||||
if key not in exclude_keys}
|
if key not in exclude_keys}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class Configuration(object):
|
|||||||
LOG.debug("Saving configuration values for %s - "
|
LOG.debug("Saving configuration values for %s - "
|
||||||
"values: %s" % (cfg_id, values))
|
"values: %s" % (cfg_id, values))
|
||||||
config_items = []
|
config_items = []
|
||||||
for key, val in values.iteritems():
|
for key, val in values.items():
|
||||||
config_item = DBConfigurationParameter.create(
|
config_item = DBConfigurationParameter.create(
|
||||||
configuration_id=cfg_id,
|
configuration_id=cfg_id,
|
||||||
configuration_key=key,
|
configuration_key=key,
|
||||||
|
@ -114,7 +114,7 @@ class ConfigurationsController(wsgi.Controller):
|
|||||||
models.DatastoreConfigurationParameters.load_parameters(
|
models.DatastoreConfigurationParameters.load_parameters(
|
||||||
datastore_version.id))
|
datastore_version.id))
|
||||||
|
|
||||||
for k, v in values.iteritems():
|
for k, v in values.items():
|
||||||
configItems.append(DBConfigurationParameter(
|
configItems.append(DBConfigurationParameter(
|
||||||
configuration_key=k,
|
configuration_key=k,
|
||||||
configuration_value=v))
|
configuration_value=v))
|
||||||
@ -219,7 +219,7 @@ class ConfigurationsController(wsgi.Controller):
|
|||||||
ds_version,
|
ds_version,
|
||||||
models.DatastoreConfigurationParameters.load_parameters(
|
models.DatastoreConfigurationParameters.load_parameters(
|
||||||
ds_version.id))
|
ds_version.id))
|
||||||
for k, v in configuration['values'].iteritems():
|
for k, v in configuration['values'].items():
|
||||||
items.append(DBConfigurationParameter(
|
items.append(DBConfigurationParameter(
|
||||||
configuration_id=group.id,
|
configuration_id=group.id,
|
||||||
configuration_key=k,
|
configuration_key=k,
|
||||||
@ -244,7 +244,7 @@ class ConfigurationsController(wsgi.Controller):
|
|||||||
"datastore: %(name)s %(version)s") % output
|
"datastore: %(name)s %(version)s") % output
|
||||||
raise exception.UnprocessableEntity(message=msg)
|
raise exception.UnprocessableEntity(message=msg)
|
||||||
|
|
||||||
for k, v in values.iteritems():
|
for k, v in values.items():
|
||||||
key = k.lower()
|
key = k.lower()
|
||||||
# parameter name validation
|
# parameter name validation
|
||||||
if key not in rules_lookup:
|
if key not in rules_lookup:
|
||||||
|
@ -88,7 +88,7 @@ class DatabaseModelBase(models.ModelBase):
|
|||||||
|
|
||||||
def merge_attributes(self, values):
|
def merge_attributes(self, values):
|
||||||
"""dict.update() behaviour."""
|
"""dict.update() behaviour."""
|
||||||
for k, v in values.iteritems():
|
for k, v in values.items():
|
||||||
self[k] = v
|
self[k] = v
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -73,7 +73,7 @@ def delete_all(query_func, model, **conditions):
|
|||||||
|
|
||||||
|
|
||||||
def update(model, **values):
|
def update(model, **values):
|
||||||
for k, v in values.iteritems():
|
for k, v in values.items():
|
||||||
model[k] = v
|
model[k] = v
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ def update_dict(updates, target):
|
|||||||
return target
|
return target
|
||||||
|
|
||||||
if updates is not None:
|
if updates is not None:
|
||||||
for k, v in updates.iteritems():
|
for k, v in updates.items():
|
||||||
if isinstance(v, collections.Mapping):
|
if isinstance(v, collections.Mapping):
|
||||||
target[k] = update_dict(v, target.get(k, {}))
|
target[k] = update_dict(v, target.get(k, {}))
|
||||||
else:
|
else:
|
||||||
|
@ -802,7 +802,7 @@ class BaseMySqlApp(object):
|
|||||||
LOG.debug("Applying overrides to MySQL.")
|
LOG.debug("Applying overrides to MySQL.")
|
||||||
with self.local_sql_client(self.get_engine()) as client:
|
with self.local_sql_client(self.get_engine()) as client:
|
||||||
LOG.debug("Updating override values in running MySQL.")
|
LOG.debug("Updating override values in running MySQL.")
|
||||||
for k, v in overrides.iteritems():
|
for k, v in overrides.items():
|
||||||
byte_value = guestagent_utils.to_bytes(v)
|
byte_value = guestagent_utils.to_bytes(v)
|
||||||
q = sql_query.SetServerVariable(key=k, value=byte_value)
|
q = sql_query.SetServerVariable(key=k, value=byte_value)
|
||||||
t = text(str(q))
|
t = text(str(q))
|
||||||
|
@ -67,8 +67,8 @@ def get_custom_managers():
|
|||||||
|
|
||||||
|
|
||||||
def datastore_registry():
|
def datastore_registry():
|
||||||
return dict(chain(defaults.iteritems(),
|
return dict(chain(defaults.items(),
|
||||||
get_custom_managers().iteritems()))
|
get_custom_managers().items()))
|
||||||
|
|
||||||
|
|
||||||
def to_gb(bytes):
|
def to_gb(bytes):
|
||||||
|
@ -414,7 +414,7 @@ class AfterConfigurationsCreation(ConfigurationsTestBase):
|
|||||||
|
|
||||||
with CollectionCheck("configuration_values", result.values) as check:
|
with CollectionCheck("configuration_values", result.values) as check:
|
||||||
# check each item has the correct type according to the rules
|
# check each item has the correct type according to the rules
|
||||||
for (item_key, item_val) in result.values.iteritems():
|
for (item_key, item_val) in result.values.items():
|
||||||
print("item_key: %s" % item_key)
|
print("item_key: %s" % item_key)
|
||||||
print("item_val: %s" % item_val)
|
print("item_val: %s" % item_val)
|
||||||
dbaas = instance_info.dbaas
|
dbaas = instance_info.dbaas
|
||||||
|
@ -37,7 +37,7 @@ class AuthProtocol(object):
|
|||||||
|
|
||||||
def _add_headers(self, env, headers):
|
def _add_headers(self, env, headers):
|
||||||
"""Add http headers to environment."""
|
"""Add http headers to environment."""
|
||||||
for (k, v) in headers.iteritems():
|
for (k, v) in headers.items():
|
||||||
env_key = self._header_to_env_var(k)
|
env_key = self._header_to_env_var(k)
|
||||||
env[env_key] = v
|
env[env_key] = v
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class FakeSwiftConnection(object):
|
|||||||
{'container': container, 'name': name})
|
{'container': container, 'name': name})
|
||||||
checksum = md5()
|
checksum = md5()
|
||||||
if self.manifest_prefix and self.manifest_name == name:
|
if self.manifest_prefix and self.manifest_name == name:
|
||||||
for object_name in sorted(self.container_objects.iterkeys()):
|
for object_name in sorted(self.container_objects):
|
||||||
object_checksum = md5(self.container_objects[object_name])
|
object_checksum = md5(self.container_objects[object_name])
|
||||||
# The manifest file etag for a HEAD or GET is the checksum of
|
# The manifest file etag for a HEAD or GET is the checksum of
|
||||||
# the concatenated checksums.
|
# the concatenated checksums.
|
||||||
|
@ -47,7 +47,7 @@ class UsageVerifier(object):
|
|||||||
"No message type %s for resource %s" %
|
"No message type %s for resource %s" %
|
||||||
(event_type, resource_id))
|
(event_type, resource_id))
|
||||||
with asserts.Check() as check:
|
with asserts.Check() as check:
|
||||||
for key, value in attrs.iteritems():
|
for key, value in attrs.items():
|
||||||
check.equal(found[key], value)
|
check.equal(found[key], value)
|
||||||
|
|
||||||
def get_messages(self, resource_id, expected_messages=None):
|
def get_messages(self, resource_id, expected_messages=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user