Replace dict.iteritems() with dict.items() in horizon

1.As mentioned in [1], we should avoid using dict.iteritems()
to achieve iterators. We can use dict.items instead, as it will
return iterators in PY3 as well. And dict.items/keys will more
readable.
2.In py2, the performance about list should be negligible,
see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.htmls

Change-Id: Idba02079d76b529b344ae96cebb7d6161c0ecbc6
This commit is contained in:
yanghuichan 2017-07-20 16:53:25 +08:00
parent 299f4c3562
commit 7adb3f548b
4 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@
</a> </a>
<ul id="sidebar-accordion-{{ dashboard.slug }}" <ul id="sidebar-accordion-{{ dashboard.slug }}"
class="nav collapse panel-collapse{% if current.slug == dashboard.slug %} in{% endif %}"> class="nav collapse panel-collapse{% if current.slug == dashboard.slug %} in{% endif %}">
{% for group, panels in panel_info.iteritems %} {% for group, panels in panel_info.items %}
{% with panels|has_permissions_on_list:user as filtered_panels %} {% with panels|has_permissions_on_list:user as filtered_panels %}
{% if filtered_panels %} {% if filtered_panels %}
{% if group.name %} {% if group.name %}

View File

@ -1,6 +1,6 @@
{% load horizon %} {% load horizon %}
{% for heading, panels in components.iteritems %} {% for heading, panels in components.items %}
{% with panels|has_permissions_on_list:user as filtered_panels %} {% with panels|has_permissions_on_list:user as filtered_panels %}
{% if filtered_panels %} {% if filtered_panels %}
{% if accessible_panels %} {% if accessible_panels %}

View File

@ -158,7 +158,7 @@ class ImagesPage(basepage.BaseNavigationPage):
def add_custom_metadata(self, name, metadata): def add_custom_metadata(self, name, metadata):
row = self._get_row_with_image_name(name) row = self._get_row_with_image_name(name)
update_metadata_form = self.images_table.update_metadata(row) update_metadata_form = self.images_table.update_metadata(row)
for field_name, value in metadata.iteritems(): for field_name, value in metadata.items():
update_metadata_form.add_custom_field(field_name, value) update_metadata_form.add_custom_field(field_name, value)
update_metadata_form.submit() update_metadata_form.submit()
@ -168,7 +168,7 @@ class ImagesPage(basepage.BaseNavigationPage):
description_page = self.images_table.go_to_image_description_page(row) description_page = self.images_table.go_to_image_description_page(row)
content = description_page.get_content() content = description_page.get_content()
for name, value in content.iteritems(): for name, value in content.items():
if name in dict_with_details: if name in dict_with_details:
if dict_with_details[name] in value: if dict_with_details[name] in value:
matches.append(True) matches.append(True)

View File

@ -17,7 +17,7 @@
</a> </a>
<ul id="sidebar-drawer-{{ dashboard.slug }}" <ul id="sidebar-drawer-{{ dashboard.slug }}"
class="nav collapse panel-collapse{% if current.slug == dashboard.slug %} in{% endif %}"> class="nav collapse panel-collapse{% if current.slug == dashboard.slug %} in{% endif %}">
{% for group, panels in panel_info.iteritems %} {% for group, panels in panel_info.items %}
{% with panels|has_permissions_on_list:user as filtered_panels %} {% with panels|has_permissions_on_list:user as filtered_panels %}
{% if filtered_panels %} {% if filtered_panels %}
{% if group.name %} {% if group.name %}