diff --git a/gapic/ads-templates/%namespace/%name/%version/__init__.py.j2 b/gapic/ads-templates/%namespace/%name/%version/__init__.py.j2 index aa12751852..3889fa1545 100644 --- a/gapic/ads-templates/%namespace/%name/%version/__init__.py.j2 +++ b/gapic/ads-templates/%namespace/%name/%version/__init__.py.j2 @@ -11,18 +11,18 @@ if sys.version_info < (3, 7): _lazy_type_to_package_map = { # Message types -{%- for message in api.top_level_messages.values() %} +{%- for _, message in api.top_level_messages|dictsort %} '{{ message.name }}': '{{ message.ident.package|join('.') }}.types.{{ message.ident.module }}', {%- endfor %} - + # Enum types -{%- for enum in api.top_level_enums.values() %} +{%- for _, enum in api.top_level_enums|dictsort %} '{{ enum.name }}': '{{ enum.ident.package|join('.') }}.types.{{enum.ident.module }}', {%- endfor %} - + {# TODO(yon-mg): add rest transport service once I know what this is #} - # Client classes and transports -{%- for service in api.services.values() %} + # Client classes and transports +{%- for _, service in api.services|dictsort %} '{{ service.client_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}', '{{ service.transport_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}.transports', '{{ service.grpc_transport_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}.transports', diff --git a/gapic/ads-templates/%namespace/%name/__init__.py.j2 b/gapic/ads-templates/%namespace/%name/__init__.py.j2 index aa12751852..322d19bcc7 100644 --- a/gapic/ads-templates/%namespace/%name/__init__.py.j2 +++ b/gapic/ads-templates/%namespace/%name/__init__.py.j2 @@ -11,18 +11,18 @@ if sys.version_info < (3, 7): _lazy_type_to_package_map = { # Message types -{%- for message in api.top_level_messages.values() %} +{%- for _, message in api.top_level_messages|dictsort %} '{{ message.name }}': '{{ message.ident.package|join('.') }}.types.{{ message.ident.module }}', {%- endfor %} - + # Enum types -{%- for enum in api.top_level_enums.values() %} +{%- for _, enum in api.top_level_enums|dictsort %} '{{ enum.name }}': '{{ enum.ident.package|join('.') }}.types.{{enum.ident.module }}', {%- endfor %} - + {# TODO(yon-mg): add rest transport service once I know what this is #} - # Client classes and transports -{%- for service in api.services.values() %} + # Client classes and transports +{%- for _, service in api.services|dictsort %} '{{ service.client_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}', '{{ service.transport_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}.transports', '{{ service.grpc_transport_name }}': '{{ service.meta.address.package|join('.') }}.services.{{ service.meta.address.module }}.transports', @@ -90,7 +90,7 @@ from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.' __all__ = ( {%- filter indent %} {% filter sort_lines -%} -{% for subpackage in api.subpackages.keys() -%} +{% for subpackage, _ in api.subpackages|dictsort -%} '{{ subpackage }}', {% endfor -%} {% for service in api.services.values()|sort(attribute='name') diff --git a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 index df685b2438..217cb20e58 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 @@ -2,7 +2,7 @@ {% block content %} {# Import subpackages. -#} -{% for subpackage in api.subpackages.keys() -%} +{% for subpackage, _ in api.subpackages|dictsort -%} from . import {{ subpackage }} {% endfor -%} diff --git a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 index 7b25899bc5..6f331c3ad9 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 @@ -1,20 +1,20 @@ {% extends '_base.py.j2' %} {% block content %} -{%- for proto in api.protos.values() if proto.file_to_generate and proto.messages %} +{%- for _, proto in api.protos|dictsort if proto.file_to_generate and proto.messages %} from .{{proto.module_name }} import ( - {%- for message in proto.messages.values() %} + {%- for _, message in proto.messages|dictsort %} {{message.name }}, {% endfor %} - {%- for enum in proto.enums.values() %} + {%- for _, enum in proto.enums|dictsort %} {{ enum.name }}, {% endfor %} ){% endfor %} __all__ = ( - {%- for proto in api.protos.values() if proto.file_to_generate %} - {%- for message in proto.messages.values() %} + {%- for _, proto in api.protos|dictsort if proto.file_to_generate %} + {%- for _, message in proto.messages|dictsort %} '{{ message.name }}', {%- endfor -%} - {%- for enum in proto.enums.values() %} + {%- for _, enum in proto.enums|dictsort %} '{{ enum.name }}', {%- endfor -%} {%- endfor %}