2
0

Use items() method instead of iteritems() for Python 3 compatibility

In Python 3, dict.items() is already an iterator while dict.iteritems() no
longer exits. In Python 2, dict.items() is not an iterator but it works
and the small performance hit doesn't really matter for the salt config
pillar data which is really small.
This commit is contained in:
Raphaël Hertzog 2014-12-23 17:38:50 +01:00
parent 2f2cd972ac
commit 8a828b506e
2 changed files with 6 additions and 6 deletions

View File

@ -613,10 +613,10 @@ fileserver_backend:
gitfs_remotes: gitfs_remotes:
{%- for remote in master['gitfs_remotes'] %} {%- for remote in master['gitfs_remotes'] %}
{%- if remote is iterable and remote is not string %} {%- if remote is iterable and remote is not string %}
{%- for repo, children in remote.iteritems() %} {%- for repo, children in remote.items() %}
- {{ repo }}: - {{ repo }}:
{%- for child in children %} {%- for child in children %}
{%- for key, value in child.iteritems() %} {%- for key, value in child.items() %}
- {{ key }}: {{ value }} - {{ key }}: {{ value }}
{%- endfor -%} {%- endfor -%}
{%- endfor -%} {%- endfor -%}
@ -942,7 +942,7 @@ win_gitrepos:
##### Halite ##### ##### Halite #####
########################################## ##########################################
halite: halite:
{% for name, value in master['halite'].iteritems() %} {% for name, value in master['halite'].items() %}
{{ name }}: {{ value }} {{ name }}: {{ value }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -951,7 +951,7 @@ halite:
##### rest_cherrypy ##### ##### rest_cherrypy #####
########################################## ##########################################
rest_cherrypy: rest_cherrypy:
{% for name, value in master['rest_cherrypy'].iteritems() %} {% for name, value in master['rest_cherrypy'].items() %}
{{ name }}: {{ value }} {{ name }}: {{ value }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@ -458,10 +458,10 @@ file_roots:
gitfs_remotes: gitfs_remotes:
{%- for remote in minion['gitfs_remotes'] %} {%- for remote in minion['gitfs_remotes'] %}
{%- if remote is iterable and remote is not string %} {%- if remote is iterable and remote is not string %}
{%- for repo, children in remote.iteritems() %} {%- for repo, children in remote.items() %}
- {{ repo }}: - {{ repo }}:
{%- for child in children %} {%- for child in children %}
{%- for key, value in child.iteritems() %} {%- for key, value in child.items() %}
- {{ key }}: {{ value }} - {{ key }}: {{ value }}
{%- endfor -%} {%- endfor -%}
{%- endfor -%} {%- endfor -%}