Merge "pylint: fix len-as-condition warning"
This commit is contained in:
commit
c9536342c2
@ -45,7 +45,6 @@ disable=
|
|||||||
expression-not-assigned,
|
expression-not-assigned,
|
||||||
global-statement,
|
global-statement,
|
||||||
invalid-name,
|
invalid-name,
|
||||||
len-as-condition,
|
|
||||||
line-too-long,
|
line-too-long,
|
||||||
misplaced-comparison-constant,
|
misplaced-comparison-constant,
|
||||||
missing-docstring,
|
missing-docstring,
|
||||||
|
@ -519,7 +519,7 @@ class Dashboard(Registry, HorizonComponent):
|
|||||||
panel_groups.append((panel_group.slug, panel_group))
|
panel_groups.append((panel_group.slug, panel_group))
|
||||||
|
|
||||||
# Deal with leftovers (such as add-on registrations)
|
# Deal with leftovers (such as add-on registrations)
|
||||||
if len(registered):
|
if registered:
|
||||||
slugs = [panel.slug for panel in registered.values()]
|
slugs = [panel.slug for panel in registered.values()]
|
||||||
new_group = PanelGroup(self,
|
new_group = PanelGroup(self,
|
||||||
slug="other",
|
slug="other",
|
||||||
@ -769,7 +769,7 @@ class Site(Registry, HorizonComponent):
|
|||||||
dashboard = self._registered(item)
|
dashboard = self._registered(item)
|
||||||
dashboards.append(dashboard)
|
dashboards.append(dashboard)
|
||||||
registered.pop(dashboard.__class__)
|
registered.pop(dashboard.__class__)
|
||||||
if len(registered):
|
if registered:
|
||||||
extra = sorted(registered.values())
|
extra = sorted(registered.values())
|
||||||
dashboards.extend(extra)
|
dashboards.extend(extra)
|
||||||
return dashboards
|
return dashboards
|
||||||
@ -785,7 +785,7 @@ class Site(Registry, HorizonComponent):
|
|||||||
"""
|
"""
|
||||||
if self.default_dashboard:
|
if self.default_dashboard:
|
||||||
return self._registered(self.default_dashboard)
|
return self._registered(self.default_dashboard)
|
||||||
elif len(self._registry):
|
elif self._registry:
|
||||||
return self.get_dashboards()[0]
|
return self.get_dashboards()[0]
|
||||||
else:
|
else:
|
||||||
raise NotRegistered("No dashboard modules have been registered.")
|
raise NotRegistered("No dashboard modules have been registered.")
|
||||||
|
@ -182,7 +182,7 @@ class OperationLogMiddleware(object):
|
|||||||
|
|
||||||
# when a file uploaded (E.g create image)
|
# when a file uploaded (E.g create image)
|
||||||
files = request.FILES.values()
|
files = request.FILES.values()
|
||||||
if len(list(files)) > 0:
|
if list(files):
|
||||||
filenames = ', '.join(
|
filenames = ', '.join(
|
||||||
[up_file.name for up_file in files])
|
[up_file.name for up_file in files])
|
||||||
params['file_name'] = filenames
|
params['file_name'] = filenames
|
||||||
|
@ -496,7 +496,7 @@ class Column(html.HTMLElement):
|
|||||||
data = [self.get_raw_data(datum) for datum in self.table.data]
|
data = [self.get_raw_data(datum) for datum in self.table.data]
|
||||||
data = [raw_data for raw_data in data if raw_data is not None]
|
data = [raw_data for raw_data in data if raw_data is not None]
|
||||||
|
|
||||||
if len(data):
|
if data:
|
||||||
try:
|
try:
|
||||||
summation = summation_function(data)
|
summation = summation_function(data)
|
||||||
for filter_func in self.filters:
|
for filter_func in self.filters:
|
||||||
|
@ -123,7 +123,7 @@ class AngularGettextHTMLParser(html_parser.HTMLParser):
|
|||||||
|
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
if self.in_translate:
|
if self.in_translate:
|
||||||
if len(self.inner_tags) > 0:
|
if self.inner_tags:
|
||||||
tag = self.inner_tags.pop()
|
tag = self.inner_tags.pop()
|
||||||
self.data += "</%s>" % tag
|
self.data += "</%s>" % tag
|
||||||
return
|
return
|
||||||
|
@ -904,7 +904,7 @@ class Workflow(html.HTMLElement):
|
|||||||
|
|
||||||
def verify_integrity(self):
|
def verify_integrity(self):
|
||||||
provided_keys = self.contributions | set(self.context_seed.keys())
|
provided_keys = self.contributions | set(self.context_seed.keys())
|
||||||
if len(self.depends_on - provided_keys):
|
if self.depends_on - provided_keys:
|
||||||
raise exceptions.NotAvailable(
|
raise exceptions.NotAvailable(
|
||||||
_("The current user has insufficient permission to complete "
|
_("The current user has insufficient permission to complete "
|
||||||
"the requested task."))
|
"the requested task."))
|
||||||
|
@ -258,7 +258,7 @@ class QuotaSet(Sequence):
|
|||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
match = [quota for quota in self.items if quota.name == key]
|
match = [quota for quota in self.items if quota.name == key]
|
||||||
return match.pop() if len(match) else Quota(key, default)
|
return match.pop() if match else Quota(key, default)
|
||||||
|
|
||||||
def add(self, other):
|
def add(self, other):
|
||||||
return self.__add__(other)
|
return self.__add__(other)
|
||||||
|
@ -634,7 +634,7 @@ def group_list(request, domain=None, project=None, user=None, filters=None):
|
|||||||
project_groups = []
|
project_groups = []
|
||||||
for group in groups:
|
for group in groups:
|
||||||
roles = roles_for_group(request, group=group.id, project=project)
|
roles = roles_for_group(request, group=group.id, project=project)
|
||||||
if roles and len(roles) > 0:
|
if roles:
|
||||||
project_groups.append(group)
|
project_groups.append(group)
|
||||||
groups = project_groups
|
groups = project_groups
|
||||||
return groups
|
return groups
|
||||||
|
@ -602,14 +602,14 @@ def server_list_paged(request,
|
|||||||
servers = [Server(s, request)
|
servers = [Server(s, request)
|
||||||
for s in nova_client.servers.list(detailed, search_opts)]
|
for s in nova_client.servers.list(detailed, search_opts)]
|
||||||
if view_marker == 'possibly_deleted':
|
if view_marker == 'possibly_deleted':
|
||||||
if len(servers) == 0:
|
if not servers:
|
||||||
view_marker = 'head_deleted'
|
view_marker = 'head_deleted'
|
||||||
search_opts['sort_dir'] = 'desc'
|
search_opts['sort_dir'] = 'desc'
|
||||||
reversed_order = False
|
reversed_order = False
|
||||||
servers = [Server(s, request)
|
servers = [Server(s, request)
|
||||||
for s in nova_client.servers.list(detailed,
|
for s in nova_client.servers.list(detailed,
|
||||||
search_opts)]
|
search_opts)]
|
||||||
if len(servers) == 0:
|
if not servers:
|
||||||
view_marker = 'tail_deleted'
|
view_marker = 'tail_deleted'
|
||||||
search_opts['sort_dir'] = 'asc'
|
search_opts['sort_dir'] = 'asc'
|
||||||
reversed_order = True
|
reversed_order = True
|
||||||
|
@ -56,7 +56,7 @@ class Users(generic.View):
|
|||||||
|
|
||||||
filters = rest_utils.parse_filters_kwargs(request,
|
filters = rest_utils.parse_filters_kwargs(request,
|
||||||
self.client_keywords)[0]
|
self.client_keywords)[0]
|
||||||
if len(filters) == 0:
|
if not filters:
|
||||||
filters = None
|
filters = None
|
||||||
|
|
||||||
result = api.keystone.user_list(
|
result = api.keystone.user_list(
|
||||||
@ -420,7 +420,7 @@ class Projects(generic.View):
|
|||||||
|
|
||||||
filters = rest_utils.parse_filters_kwargs(request,
|
filters = rest_utils.parse_filters_kwargs(request,
|
||||||
self.client_keywords)[0]
|
self.client_keywords)[0]
|
||||||
if len(filters) == 0:
|
if not filters:
|
||||||
filters = None
|
filters = None
|
||||||
|
|
||||||
paginate = request.GET.get('paginate') == 'true'
|
paginate = request.GET.get('paginate') == 'true'
|
||||||
|
@ -89,7 +89,7 @@ def list_traces(request):
|
|||||||
def get_trace(request, trace_id):
|
def get_trace(request, trace_id):
|
||||||
def rec(_data, level=0):
|
def rec(_data, level=0):
|
||||||
_data['level'] = level
|
_data['level'] = level
|
||||||
_data['is_leaf'] = not len(_data['children'])
|
_data['is_leaf'] = not _data['children']
|
||||||
_data['visible'] = True
|
_data['visible'] = True
|
||||||
_data['childrenVisible'] = True
|
_data['childrenVisible'] = True
|
||||||
finished = _data['info']['finished']
|
finished = _data['info']['finished']
|
||||||
|
@ -59,8 +59,7 @@ def show_endpoints(datanum):
|
|||||||
if 'endpoints' in datanum:
|
if 'endpoints' in datanum:
|
||||||
template_name = 'admin/info/_cell_endpoints_v2.html'
|
template_name = 'admin/info/_cell_endpoints_v2.html'
|
||||||
context = None
|
context = None
|
||||||
if (len(datanum['endpoints']) > 0 and
|
if (datanum['endpoints'] and "publicURL" in datanum['endpoints'][0]):
|
||||||
"publicURL" in datanum['endpoints'][0]):
|
|
||||||
context = datanum['endpoints'][0]
|
context = datanum['endpoints'][0]
|
||||||
else:
|
else:
|
||||||
# this is a keystone v3 version of endpoints
|
# this is a keystone v3 version of endpoints
|
||||||
|
@ -238,7 +238,7 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
network_type_choices = [
|
network_type_choices = [
|
||||||
(net_type, self.provider_types[net_type]['display_name'])
|
(net_type, self.provider_types[net_type]['display_name'])
|
||||||
for net_type in supported_provider_types]
|
for net_type in supported_provider_types]
|
||||||
if len(network_type_choices) == 0:
|
if not network_type_choices:
|
||||||
self._hide_provider_network_type()
|
self._hide_provider_network_type()
|
||||||
else:
|
else:
|
||||||
self.fields['network_type'].choices = network_type_choices
|
self.fields['network_type'].choices = network_type_choices
|
||||||
|
@ -368,7 +368,7 @@ class UpdateDomain(workflows.Workflow):
|
|||||||
]
|
]
|
||||||
admin_role_ids = [role for role in current_role_ids
|
admin_role_ids = [role for role in current_role_ids
|
||||||
if role in available_admin_role_ids]
|
if role in available_admin_role_ids]
|
||||||
if len(admin_role_ids):
|
if admin_role_ids:
|
||||||
removing_admin = any([role in current_role_ids
|
removing_admin = any([role in current_role_ids
|
||||||
for role in admin_role_ids])
|
for role in admin_role_ids])
|
||||||
else:
|
else:
|
||||||
|
@ -54,8 +54,7 @@ class IndexView(tables.DataTableView):
|
|||||||
# selected, then search criteria must be provided and
|
# selected, then search criteria must be provided and
|
||||||
# return an empty list
|
# return an empty list
|
||||||
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
||||||
if filter_first.get('identity.groups', False) \
|
if filter_first.get('identity.groups', False) and not filters:
|
||||||
and len(filters) == 0:
|
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
|
@ -96,8 +96,7 @@ class IndexView(tables.DataTableView):
|
|||||||
# selected, then search criteria must be provided and
|
# selected, then search criteria must be provided and
|
||||||
# return an empty list
|
# return an empty list
|
||||||
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
||||||
if filter_first.get('identity.projects', False) and len(
|
if filter_first.get('identity.projects', False) and not filters:
|
||||||
filters) == 0:
|
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
self._more = False
|
self._more = False
|
||||||
return tenants
|
return tenants
|
||||||
|
@ -752,7 +752,7 @@ class UpdateProject(workflows.Workflow):
|
|||||||
if role.name.lower() in _admin_roles]
|
if role.name.lower() in _admin_roles]
|
||||||
admin_roles = [role for role in current_role_ids
|
admin_roles = [role for role in current_role_ids
|
||||||
if role in available_admin_role_ids]
|
if role in available_admin_role_ids]
|
||||||
if len(admin_roles):
|
if admin_roles:
|
||||||
removing_admin = any([role in current_role_ids
|
removing_admin = any([role in current_role_ids
|
||||||
for role in admin_roles])
|
for role in admin_roles])
|
||||||
else:
|
else:
|
||||||
|
@ -52,7 +52,7 @@ class IndexView(tables.DataTableView):
|
|||||||
# selected, then search criteria must be provided
|
# selected, then search criteria must be provided
|
||||||
# and return an empty list
|
# and return an empty list
|
||||||
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
||||||
if filter_first.get('identity.roles', False) and len(filters) == 0:
|
if filter_first.get('identity.roles', False) and not filters:
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return roles
|
return roles
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class IndexView(tables.DataTableView):
|
|||||||
# selected, then search criteria must be provided
|
# selected, then search criteria must be provided
|
||||||
# and return an empty list
|
# and return an empty list
|
||||||
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
|
||||||
if filter_first.get('identity.users', False) and len(filters) == 0:
|
if filter_first.get('identity.users', False) and not filters:
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return users
|
return users
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
|
|||||||
else:
|
else:
|
||||||
search_opts = {'consistentcygroup_id': data['cgroup_id']}
|
search_opts = {'consistentcygroup_id': data['cgroup_id']}
|
||||||
volumes = cinder.volume_list(request, search_opts=search_opts)
|
volumes = cinder.volume_list(request, search_opts=search_opts)
|
||||||
if len(volumes) == 0:
|
if not volumes:
|
||||||
msg = _('Unable to create snapshot. Consistency group '
|
msg = _('Unable to create snapshot. Consistency group '
|
||||||
'must contain volumes.')
|
'must contain volumes.')
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ class CloneCGroupForm(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
search_opts = {'consistentcygroup_id': data['cgroup_id']}
|
search_opts = {'consistentcygroup_id': data['cgroup_id']}
|
||||||
volumes = cinder.volume_list(request, search_opts=search_opts)
|
volumes = cinder.volume_list(request, search_opts=search_opts)
|
||||||
if len(volumes) == 0:
|
if not volumes:
|
||||||
msg = _('Unable to clone empty consistency group.')
|
msg = _('Unable to clone empty consistency group.')
|
||||||
|
|
||||||
exceptions.handle(request,
|
exceptions.handle(request,
|
||||||
|
@ -347,7 +347,7 @@ class AttachInterface(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
choices = [('network', _("by Network (and IP address)"))]
|
choices = [('network', _("by Network (and IP address)"))]
|
||||||
ports = instance_utils.port_field_data(request, with_network=True)
|
ports = instance_utils.port_field_data(request, with_network=True)
|
||||||
if len(ports) > 0:
|
if ports:
|
||||||
self.fields['port'].choices = ports
|
self.fields['port'].choices = ports
|
||||||
choices.append(('port', _("by Port")))
|
choices.append(('port', _("by Port")))
|
||||||
|
|
||||||
|
@ -235,10 +235,10 @@ class CreateSubnetInfoAction(workflows.Action):
|
|||||||
# Populate data-fields for switching the prefixlen field
|
# Populate data-fields for switching the prefixlen field
|
||||||
# when user selects a subnetpool other than
|
# when user selects a subnetpool other than
|
||||||
# "Provider default pool"
|
# "Provider default pool"
|
||||||
for (id, name) in self.fields['subnetpool'].choices:
|
for (id_, name) in self.fields['subnetpool'].choices:
|
||||||
if not len(id):
|
if not id_:
|
||||||
continue
|
continue
|
||||||
key = 'data-subnetpool-' + id
|
key = 'data-subnetpool-' + id_
|
||||||
self.fields['prefixlen'].widget.attrs[key] = \
|
self.fields['prefixlen'].widget.attrs[key] = \
|
||||||
_('Network Mask')
|
_('Network Mask')
|
||||||
else:
|
else:
|
||||||
@ -555,9 +555,9 @@ class CreateNetwork(workflows.Workflow):
|
|||||||
params['gateway_ip'] = None
|
params['gateway_ip'] = None
|
||||||
elif data['gateway_ip']:
|
elif data['gateway_ip']:
|
||||||
params['gateway_ip'] = data['gateway_ip']
|
params['gateway_ip'] = data['gateway_ip']
|
||||||
if 'subnetpool' in data and len(data['subnetpool']):
|
if 'subnetpool' in data and data['subnetpool']:
|
||||||
params['subnetpool_id'] = data['subnetpool']
|
params['subnetpool_id'] = data['subnetpool']
|
||||||
if 'prefixlen' in data and len(data['prefixlen']):
|
if 'prefixlen' in data and data['prefixlen']:
|
||||||
params['prefixlen'] = data['prefixlen']
|
params['prefixlen'] = data['prefixlen']
|
||||||
|
|
||||||
self._setup_subnet_parameters(params, data)
|
self._setup_subnet_parameters(params, data)
|
||||||
|
@ -136,7 +136,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
|
|||||||
search_opts = {'group_id': group_id}
|
search_opts = {'group_id': group_id}
|
||||||
volumes = cinder.volume_list(request,
|
volumes = cinder.volume_list(request,
|
||||||
search_opts=search_opts)
|
search_opts=search_opts)
|
||||||
if len(volumes) == 0:
|
if not volumes:
|
||||||
msg = _('Unable to create snapshot. '
|
msg = _('Unable to create snapshot. '
|
||||||
'group must contain volumes.')
|
'group must contain volumes.')
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ class CloneGroupForm(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
search_opts = {'group_id': group_id}
|
search_opts = {'group_id': group_id}
|
||||||
volumes = cinder.volume_list(request, search_opts=search_opts)
|
volumes = cinder.volume_list(request, search_opts=search_opts)
|
||||||
if len(volumes) == 0:
|
if not volumes:
|
||||||
msg = _('Unable to clone empty group.')
|
msg = _('Unable to clone empty group.')
|
||||||
|
|
||||||
exceptions.handle(request,
|
exceptions.handle(request,
|
||||||
|
Loading…
Reference in New Issue
Block a user