Skip to content

Commit

Permalink
[fix] Alphabetically sort lines in a few more spots. (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sneeringer authored and software-dov committed Jul 19, 2019
1 parent 56e6516 commit 695618c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,32 @@ from . import {{ subpackage }}
{% endfor -%}

{# Import services for this package. -#}
{% filter sort_lines -%}
{% for service in api.services.values()|sort(attribute='name')
if service.meta.address.subpackage == api.subpackage_view -%}
from .services.{{ service.name|snake_case }} import {{ service.name }}
{% endfor -%}
{% endfilter -%}

{# Import messages from each proto.
It is safe to import all of the messages into the same namespace here,
because protocol buffers itself enforces selector uniqueness within
a proto package.
-#}
{% filter sort_lines -%}
{% for proto in api.protos.values()|sort(attribute='module_name')
if proto.meta.address.subpackage == api.subpackage_view -%}
{% for message in proto.messages.values()|sort(attribute='name') -%}
from .types.{{ proto.module_name }} import {{ message.name }}
{% endfor %}{% endfor %}
{% endfor %}{% endfor -%}
{% endfilter %}

{# Define __all__.
This requires the full set of imported names, so we iterate over
them again.
-#}
__all__ = (
{%- filter sort_lines %}
{%- for subpackage in api.subpackages.keys() %}
'{{ subpackage }}',
{%- endfor %}
Expand All @@ -40,5 +45,6 @@ __all__ = (
{%- for message in proto.messages.values()|sort(attribute='name') %}
'{{ message.name }}',
{%- endfor %}{% endfor %}
{%- endfilter %}
)
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import proto{% if p != 'proto' %} as {{ p }}{% endif %} # type: ignore
{% endif %}

{% filter sort_lines -%}
{% for import_ in proto.python_modules -%}
{{ import_ }}
{% endfor %}
{% endfor -%}
{% endfilter %}


__protobuf__ = {{ p }}.module(
package='{{ '.'.join(proto.meta.address.package) }}',
Expand Down

0 comments on commit 695618c

Please sign in to comment.