This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy path__init__.py.j2
More file actions
61 lines (56 loc) · 2.03 KB
/
__init__.py.j2
File metadata and controls
61 lines (56 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{% extends '_base.py.j2' %}
{% block content %}
{# Import subpackages. -#}
{% for subpackage, _ in api.subpackages|dictsort %}
from . import {{ subpackage }}
{% endfor %}
{# Import services for this package. -#}
{% 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.client_name }}
{% if 'grpc' in opts.transport %}
from .services.{{ service.name|snake_case }} import {{ service.async_client_name }}
{% endif %}
{% endfor %}
{# Import messages and enums 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.
-#}
{% for proto in api.protos.values()|sort(attribute='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 %}
{% for enum in proto.enums.values()|sort(attribute='name') %}
from .types.{{ proto.module_name }} import {{ enum.name }}
{% endfor %}
{% endfor %}
{# 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 -%}
'{{ subpackage }}',
{% endfor -%}
{% for service in api.services.values()
if service.meta.address.subpackage == api.subpackage_view -%}
'{{ service.client_name }}',
{% if 'grpc' in opts.transport %}
'{{ service.async_client_name }}',
{% endif %}
{% endfor -%}
{% for proto in api.protos.values()
if proto.meta.address.subpackage == api.subpackage_view -%}
{% for message in proto.messages.values()|sort(attribute='name') -%}
'{{ message.name }}',
{% endfor -%}
{% for enum in proto.enums.values() -%}
'{{ enum.name }}',
{% endfor -%}
{% endfor -%}
{% endfilter %}
)
{% endblock %}