Replace six.iteritems() with .items()
we should avoid using six.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items/keys will be more readable. In py2, the performance about list should be negligible Change-Id: I153d91e884ef0ea0a760527f3dab2b8d5ed3e38e
This commit is contained in:
parent
8774d1b021
commit
039395f7ee
|
@ -79,7 +79,7 @@ def build_stats_message():
|
|||
'seq': SEQ, "listeners": {}}
|
||||
SEQ += 1
|
||||
stat_sock_files = list_sock_stat_files()
|
||||
for listener_id, stat_sock_file in six.iteritems(stat_sock_files):
|
||||
for listener_id, stat_sock_file in stat_sock_files.items():
|
||||
listener_dict = {'pools': {},
|
||||
'status': 'DOWN',
|
||||
'stats': {
|
||||
|
@ -100,7 +100,7 @@ def build_stats_message():
|
|||
listener_dict['stats']['totconns'] = int(row['stot'])
|
||||
listener_dict['stats']['ereq'] = int(row['ereq'])
|
||||
listener_dict['status'] = row['status']
|
||||
for oid, pool in six.iteritems(pool_status):
|
||||
for oid, pool in pool_status.items():
|
||||
if oid != listener_id:
|
||||
pool_id = oid
|
||||
pools = listener_dict['pools']
|
||||
|
|
|
@ -20,7 +20,6 @@ import sys
|
|||
import gunicorn.app.base
|
||||
from oslo_config import cfg
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
import six
|
||||
|
||||
from octavia.amphorae.backends.agent.api_server import server
|
||||
from octavia.amphorae.backends.health_daemon import health_daemon
|
||||
|
@ -41,10 +40,10 @@ class AmphoraAgent(gunicorn.app.base.BaseApplication):
|
|||
|
||||
def load_config(self):
|
||||
config = dict(
|
||||
[(key, value) for key, value in six.iteritems(self.options)
|
||||
[(key, value) for key, value in self.options.items()
|
||||
if key in self.cfg.settings and value is not None]
|
||||
)
|
||||
for key, value in six.iteritems(config):
|
||||
for key, value in config.items():
|
||||
self.cfg.set(key.lower(), value)
|
||||
|
||||
def load(self):
|
||||
|
|
|
@ -16,7 +16,6 @@ import datetime
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import sqlalchemy
|
||||
from stevedore import driver as stevedore_driver
|
||||
|
||||
|
@ -118,7 +117,7 @@ class UpdateHealthDb(object):
|
|||
lb_status = constants.ONLINE
|
||||
|
||||
# update listener and nodes db information
|
||||
for listener_id, listener in six.iteritems(listeners):
|
||||
for listener_id, listener in listeners.items():
|
||||
|
||||
listener_status = None
|
||||
# OPEN = HAProxy listener status nbconn < maxconn
|
||||
|
@ -144,7 +143,7 @@ class UpdateHealthDb(object):
|
|||
LOG.error(_LE("Listener %s is not in DB"), listener_id)
|
||||
|
||||
pools = listener['pools']
|
||||
for pool_id, pool in six.iteritems(pools):
|
||||
for pool_id, pool in pools.items():
|
||||
|
||||
pool_status = None
|
||||
# UP = HAProxy backend has working or no servers
|
||||
|
@ -160,7 +159,7 @@ class UpdateHealthDb(object):
|
|||
'status': pool.get('status')})
|
||||
|
||||
members = pool['members']
|
||||
for member_id, status in six.iteritems(members):
|
||||
for member_id, status in members.items():
|
||||
|
||||
member_status = None
|
||||
if status == constants.UP:
|
||||
|
@ -257,7 +256,7 @@ class UpdateStatsDb(stats.StatsMixin):
|
|||
|
||||
amphora_id = health_message['id']
|
||||
listeners = health_message['listeners']
|
||||
for listener_id, listener in six.iteritems(listeners):
|
||||
for listener_id, listener in listeners.items():
|
||||
|
||||
stats = listener.get('stats')
|
||||
stats = {'bytes_in': stats['rx'], 'bytes_out': stats['tx'],
|
||||
|
|
|
@ -25,7 +25,6 @@ from oslo_db import exception as db_exception
|
|||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from octavia.common import constants as consts
|
||||
from octavia.common import data_models
|
||||
|
@ -1187,7 +1186,7 @@ class QuotasRepository(BaseRepository):
|
|||
if not quotas:
|
||||
quotas = models.Quotas(project_id=project_id)
|
||||
|
||||
for key, val in six.iteritems(kwargs_quota):
|
||||
for key, val in kwargs_quota.items():
|
||||
setattr(quotas, key, val)
|
||||
session.add(quotas)
|
||||
session.flush()
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
import re
|
||||
|
||||
import pep8
|
||||
import six
|
||||
|
||||
"""
|
||||
Guidelines for writing new hacking checks
|
||||
|
@ -48,7 +47,7 @@ _all_log_levels = {
|
|||
'exception': '_LE',
|
||||
}
|
||||
log_translation_hints = []
|
||||
for level, hint in six.iteritems(_all_log_levels):
|
||||
for level, hint in _all_log_levels.items():
|
||||
r = "(.)*LOG\.%(level)s\(\s*((%(wrong_hints)s)\(|'|\")" % {
|
||||
'level': level,
|
||||
'wrong_hints': '|'.join(_all_hints - set([hint])),
|
||||
|
|
Loading…
Reference in New Issue