pylint: Fix consider-using-(dict|set)-comprehension
Change-Id: I81c694c17106c179a53326a12e78cfa899872970
This commit is contained in:
parent
220b1346bd
commit
59beb951a3
|
@ -79,9 +79,7 @@ disable=
|
||||||
# "R" Refactor recommendations
|
# "R" Refactor recommendations
|
||||||
chained-comparison,
|
chained-comparison,
|
||||||
comparison-with-itself,
|
comparison-with-itself,
|
||||||
consider-using-dict-comprehension,
|
|
||||||
consider-using-in,
|
consider-using-in,
|
||||||
consider-using-set-comprehension,
|
|
||||||
cyclic-import, # TODO
|
cyclic-import, # TODO
|
||||||
duplicate-code,
|
duplicate-code,
|
||||||
inconsistent-return-statements, # TODO
|
inconsistent-return-statements, # TODO
|
||||||
|
|
|
@ -653,8 +653,8 @@ class Row(html.HTMLElement):
|
||||||
def status(self):
|
def status(self):
|
||||||
column_names = self.table._meta.status_columns
|
column_names = self.table._meta.status_columns
|
||||||
if column_names:
|
if column_names:
|
||||||
statuses = dict([(column_name, self.cells[column_name].status) for
|
statuses = dict((column_name, self.cells[column_name].status) for
|
||||||
column_name in column_names])
|
column_name in column_names)
|
||||||
return self.table.calculate_row_status(statuses)
|
return self.table.calculate_row_status(statuses)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -676,9 +676,9 @@ class Workflow(html.HTMLElement):
|
||||||
# registered and ordered.
|
# registered and ordered.
|
||||||
self.context = WorkflowContext(self)
|
self.context = WorkflowContext(self)
|
||||||
context_seed = context_seed or {}
|
context_seed = context_seed or {}
|
||||||
clean_seed = dict([(key, val)
|
clean_seed = dict((key, val)
|
||||||
for key, val in context_seed.items()
|
for key, val in context_seed.items()
|
||||||
if key in self.contributions | self.depends_on])
|
if key in self.contributions | self.depends_on)
|
||||||
self.context_seed = clean_seed
|
self.context_seed = clean_seed
|
||||||
self.context.update(clean_seed)
|
self.context.update(clean_seed)
|
||||||
|
|
||||||
|
|
|
@ -687,13 +687,13 @@ class FloatingIpManager(object):
|
||||||
else:
|
else:
|
||||||
router_ports = [p for p in ports
|
router_ports = [p for p in ports
|
||||||
if p.device_owner in ROUTER_INTERFACE_OWNERS]
|
if p.device_owner in ROUTER_INTERFACE_OWNERS]
|
||||||
reachable_subnets = set([p.fixed_ips[0]['subnet_id']
|
reachable_subnets = set(p.fixed_ips[0]['subnet_id']
|
||||||
for p in router_ports
|
for p in router_ports
|
||||||
if p.device_id in gw_routers])
|
if p.device_id in gw_routers)
|
||||||
# we have to include any shared subnets as well because we may not
|
# we have to include any shared subnets as well because we may not
|
||||||
# have permission to see the router interface to infer connectivity
|
# have permission to see the router interface to infer connectivity
|
||||||
shared = set([s.id for n in network_list(self.request, shared=True)
|
shared = set(s.id for n in network_list(self.request, shared=True)
|
||||||
for s in n.subnets])
|
for s in n.subnets)
|
||||||
return reachable_subnets | shared
|
return reachable_subnets | shared
|
||||||
|
|
||||||
@profiler.trace
|
@profiler.trace
|
||||||
|
@ -1012,7 +1012,7 @@ def network_list(request, **params):
|
||||||
networks = neutronclient(request).list_networks(**params).get('networks')
|
networks = neutronclient(request).list_networks(**params).get('networks')
|
||||||
# Get subnet list to expand subnet info in network list.
|
# Get subnet list to expand subnet info in network list.
|
||||||
subnets = subnet_list(request)
|
subnets = subnet_list(request)
|
||||||
subnet_dict = dict([(s['id'], s) for s in subnets])
|
subnet_dict = dict((s['id'], s) for s in subnets)
|
||||||
# Expand subnet list from subnet_id to values.
|
# Expand subnet list from subnet_id to values.
|
||||||
for n in networks:
|
for n in networks:
|
||||||
# Due to potential timing issues, we can't assume the subnet_dict data
|
# Due to potential timing issues, we can't assume the subnet_dict data
|
||||||
|
@ -1328,14 +1328,14 @@ def port_list_with_trunk_types(request, **params):
|
||||||
if 'tenant_id' in params:
|
if 'tenant_id' in params:
|
||||||
trunk_filters['tenant_id'] = params['tenant_id']
|
trunk_filters['tenant_id'] = params['tenant_id']
|
||||||
trunks = neutronclient(request).list_trunks(**trunk_filters)['trunks']
|
trunks = neutronclient(request).list_trunks(**trunk_filters)['trunks']
|
||||||
parent_ports = set([t['port_id'] for t in trunks])
|
parent_ports = set(t['port_id'] for t in trunks)
|
||||||
# Create a dict map for child ports (port ID to trunk info)
|
# Create a dict map for child ports (port ID to trunk info)
|
||||||
child_ports = dict([(s['port_id'],
|
child_ports = dict((s['port_id'],
|
||||||
{'trunk_id': t['id'],
|
{'trunk_id': t['id'],
|
||||||
'segmentation_type': s['segmentation_type'],
|
'segmentation_type': s['segmentation_type'],
|
||||||
'segmentation_id': s['segmentation_id']})
|
'segmentation_id': s['segmentation_id']})
|
||||||
for t in trunks
|
for t in trunks
|
||||||
for s in t['sub_ports']])
|
for s in t['sub_ports'])
|
||||||
|
|
||||||
def _get_port_info(port):
|
def _get_port_info(port):
|
||||||
if port['id'] in parent_ports:
|
if port['id'] in parent_ports:
|
||||||
|
|
|
@ -85,13 +85,13 @@ class IndexView(tables.DataTableView):
|
||||||
exceptions.handle(
|
exceptions.handle(
|
||||||
self.request,
|
self.request,
|
||||||
_('Unable to retrieve instance list.'))
|
_('Unable to retrieve instance list.'))
|
||||||
instances_dict = dict([(obj.id, obj.name) for obj in instances])
|
instances_dict = dict((obj.id, obj.name) for obj in instances)
|
||||||
|
|
||||||
tenants = get_tenant_list(self.request)
|
tenants = get_tenant_list(self.request)
|
||||||
tenant_dict = OrderedDict([(t.id, t) for t in tenants])
|
tenant_dict = OrderedDict([(t.id, t) for t in tenants])
|
||||||
|
|
||||||
pools = get_floatingip_pools(self.request)
|
pools = get_floatingip_pools(self.request)
|
||||||
pool_dict = dict([(obj.id, obj.name) for obj in pools])
|
pool_dict = dict((obj.id, obj.name) for obj in pools)
|
||||||
|
|
||||||
for ip in floating_ips:
|
for ip in floating_ips:
|
||||||
ip.instance_name = instances_dict.get(ip.instance_id)
|
ip.instance_name = instances_dict.get(ip.instance_id)
|
||||||
|
|
|
@ -107,7 +107,7 @@ class IndexView(tables.DataTableView):
|
||||||
msg = _('Unable to retrieve project list.')
|
msg = _('Unable to retrieve project list.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
|
||||||
tenant_dict = dict([(t.id, t.name) for t in tenants])
|
tenant_dict = dict((t.id, t.name) for t in tenants)
|
||||||
|
|
||||||
for image in images:
|
for image in images:
|
||||||
image.tenant_name = tenant_dict.get(image.owner)
|
image.tenant_name = tenant_dict.get(image.owner)
|
||||||
|
|
|
@ -87,7 +87,7 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView):
|
||||||
# Gather our tenants to correlate against IDs
|
# Gather our tenants to correlate against IDs
|
||||||
try:
|
try:
|
||||||
tenants, __ = api.keystone.tenant_list(self.request)
|
tenants, __ = api.keystone.tenant_list(self.request)
|
||||||
return dict([(t.id, t) for t in tenants])
|
return dict((t.id, t) for t in tenants)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _('Unable to retrieve instance project information.')
|
msg = _('Unable to retrieve instance project information.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
@ -112,7 +112,7 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView):
|
||||||
# Gather our flavors to correlate against IDs
|
# Gather our flavors to correlate against IDs
|
||||||
try:
|
try:
|
||||||
flavors = api.nova.flavor_list(self.request)
|
flavors = api.nova.flavor_list(self.request)
|
||||||
return dict([(str(flavor.id), flavor) for flavor in flavors])
|
return dict((str(flavor.id), flavor) for flavor in flavors)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _("Unable to retrieve flavor list.")
|
msg = _("Unable to retrieve flavor list.")
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
|
|
@ -57,7 +57,7 @@ class IndexView(tables.DataTableView):
|
||||||
msg = _("Unable to retrieve information about the "
|
msg = _("Unable to retrieve information about the "
|
||||||
"policies' networks.")
|
"policies' networks.")
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
return dict([(n.id, n.name) for n in networks])
|
return dict((n.id, n.name) for n in networks)
|
||||||
|
|
||||||
def _get_qos_policies(self):
|
def _get_qos_policies(self):
|
||||||
qos_policies = []
|
qos_policies = []
|
||||||
|
@ -69,7 +69,7 @@ class IndexView(tables.DataTableView):
|
||||||
msg = _("Unable to retrieve information about the "
|
msg = _("Unable to retrieve information about the "
|
||||||
"policies' qos policies.")
|
"policies' qos policies.")
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
return dict([(q.id, q.name) for q in qos_policies])
|
return dict((q.id, q.name) for q in qos_policies)
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -62,7 +62,7 @@ class SnapshotsView(tables.PagedTableMixin, tables.DataTableView):
|
||||||
msg = _('Unable to retrieve volume project information.')
|
msg = _('Unable to retrieve volume project information.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
|
||||||
tenant_dict = dict([(t.id, t) for t in tenants])
|
tenant_dict = dict((t.id, t) for t in tenants)
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
volume = volumes.get(snapshot.volume_id)
|
volume = volumes.get(snapshot.volume_id)
|
||||||
tenant_id = getattr(volume,
|
tenant_id = getattr(volume,
|
||||||
|
|
|
@ -110,7 +110,7 @@ class IndexView(tables.DataTableView):
|
||||||
floating_ip_pools = []
|
floating_ip_pools = []
|
||||||
exceptions.handle(self.request,
|
exceptions.handle(self.request,
|
||||||
_('Unable to retrieve floating IP pools.'))
|
_('Unable to retrieve floating IP pools.'))
|
||||||
pool_dict = dict([(obj.id, obj.name) for obj in floating_ip_pools])
|
pool_dict = dict((obj.id, obj.name) for obj in floating_ip_pools)
|
||||||
|
|
||||||
attached_instance_ids = [ip.instance_id for ip in floating_ips
|
attached_instance_ids = [ip.instance_id for ip in floating_ips
|
||||||
if ip.instance_id is not None]
|
if ip.instance_id is not None]
|
||||||
|
@ -126,7 +126,7 @@ class IndexView(tables.DataTableView):
|
||||||
exceptions.handle(self.request,
|
exceptions.handle(self.request,
|
||||||
_('Unable to retrieve instance list.'))
|
_('Unable to retrieve instance list.'))
|
||||||
|
|
||||||
instances_dict = dict([(obj.id, obj.name) for obj in instances])
|
instances_dict = dict((obj.id, obj.name) for obj in instances)
|
||||||
|
|
||||||
for ip in floating_ips:
|
for ip in floating_ips:
|
||||||
ip.instance_name = instances_dict.get(ip.instance_id)
|
ip.instance_name = instances_dict.get(ip.instance_id)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView):
|
||||||
# Gather our flavors to correlate our instances to them
|
# Gather our flavors to correlate our instances to them
|
||||||
try:
|
try:
|
||||||
flavors = api.nova.flavor_list(self.request)
|
flavors = api.nova.flavor_list(self.request)
|
||||||
return dict([(str(flavor.id), flavor) for flavor in flavors])
|
return dict((str(flavor.id), flavor) for flavor in flavors)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(self.request, ignore=True)
|
exceptions.handle(self.request, ignore=True)
|
||||||
return {}
|
return {}
|
||||||
|
@ -83,7 +83,7 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView):
|
||||||
try:
|
try:
|
||||||
# TODO(gabriel): Handle pagination.
|
# TODO(gabriel): Handle pagination.
|
||||||
images = api.glance.image_list_detailed(self.request)[0]
|
images = api.glance.image_list_detailed(self.request)[0]
|
||||||
return dict([(str(image.id), image) for image in images])
|
return dict((str(image.id), image) for image in images)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(self.request, ignore=True)
|
exceptions.handle(self.request, ignore=True)
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -88,7 +88,7 @@ class VolumeTableMixIn(object):
|
||||||
self.request, search_opts=search_opts)
|
self.request, search_opts=search_opts)
|
||||||
if snapshots:
|
if snapshots:
|
||||||
# extract out the volume ids
|
# extract out the volume ids
|
||||||
volume_ids = set([(s.volume_id) for s in snapshots])
|
volume_ids = set(s.volume_id for s in snapshots)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(self.request,
|
exceptions.handle(self.request,
|
||||||
_("Unable to retrieve snapshot list."))
|
_("Unable to retrieve snapshot list."))
|
||||||
|
|
Loading…
Reference in New Issue