Skip to content

Commit

Permalink
Avoid iteritems
Browse files Browse the repository at this point in the history
  • Loading branch information
enolfc authored and alvarolopez committed Apr 25, 2019
1 parent a77e54e commit 4f475f3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion caso/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, message=None, **kwargs):
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception('Exception in string format operation')
for name, value in kwargs.iteritems():
for name, value in six.iteritems(kwargs):
LOG.error("%s: %s" % (name, value))
six.reraise(exc_info[0], exc_info[1], exc_info[2])

Expand Down
2 changes: 1 addition & 1 deletion caso/extract/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self):
raise
else:
self.voms_map = {}
for vo, vomap in mapping.iteritems():
for vo, vomap in six.iteritems(mapping):
tenant = vomap.get("tenant", None)
tenants = vomap.get("tenants", [])
if tenant is not None:
Expand Down
3 changes: 2 additions & 1 deletion caso/messenger/logstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from oslo_config import cfg
from oslo_log import log
import six

from caso import exception
import caso.messenger
Expand Down Expand Up @@ -52,7 +53,7 @@ def push(self, records):
"""Push records to logstash using tcp."""
try:
self.sock.connect((self.host, self.port))
for _, record in records.iteritems():
for _, record in six.iteritems(records):
self.sock.sendall(record.as_json() + "\n")
except socket.error as e:
raise exception.LogstashConnectionError(host=self.host,
Expand Down
3 changes: 2 additions & 1 deletion caso/messenger/noop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.

from oslo_log import log
import six

import caso.messenger

Expand All @@ -25,5 +26,5 @@ class NoopMessenger(caso.messenger.BaseMessenger):
"""Noop messenger that does nothing."""
def push(self, records):
"""Push records to nowhere."""
for uuid, _ in records.iteritems():
for uuid, _ in six.iteritems(records):
LOG.info("nooping %s" % uuid)
4 changes: 2 additions & 2 deletions caso/messenger/ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def push(self, records):
return

entries = []
for _, record in records.iteritems():
for _, record in six.iteritems(records):
aux = ""
for k, v in record.as_dict(version=self.version).iteritems():
for k, v in six.iteritems(record.as_dict(version=self.version)):
if v is not None:
aux += "%s: %s\n" % (k, v)
entries.append(aux)
Expand Down

0 comments on commit 4f475f3

Please sign in to comment.