forked from googleapis/gapic-generator-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py.j2
More file actions
71 lines (69 loc) · 3.05 KB
/
__init__.py.j2
File metadata and controls
71 lines (69 loc) · 3.05 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
62
63
64
65
66
67
68
69
70
71
{% extends '_base.py.j2' %}
{% block content %}
{# Import subpackages. -#}
{% filter sort_lines -%}
{% for subpackage in api.subpackages.keys() -%}
from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif -%}
{{ api.naming.versioned_module_name }} 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 {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif -%}
{{ api.naming.versioned_module_name }}.services.{{ service.name|snake_case }}.client import {{ service.client_name }}
{%- if 'grpc' in opts.transport %}
from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif -%}
{{ api.naming.versioned_module_name }}.services.{{ service.name|snake_case }}.async_client 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.
-#}
{# 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.
-#}
{% 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 {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif -%}
{{ api.naming.versioned_module_name }}.types.{{ proto.module_name }} import {{ message.name }}
{% endfor -%}
{% for enum in proto.enums.values()|sort(attribute='name') -%}
from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif -%}
{{ api.naming.versioned_module_name }}.types.{{ proto.module_name }} import {{ enum.name }}
{% endfor %}{% endfor -%}
{% endfilter %}
{# Define __all__.
This requires the full set of imported names, so we iterate over
them again.
-#}
__all__ = (
{%- filter indent %}
{% filter sort_lines -%}
{% for subpackage in api.subpackages.keys() -%}
'{{ subpackage }}',
{% endfor -%}
{% for service in api.services.values()|sort(attribute='name')
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()|sort(attribute='module_name')
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()|sort(attribute='name')
if proto.meta.address.subpackage == api.subpackage_view -%}
'{{ enum.name }}',
{% endfor -%}{% endfor -%}
{% endfilter -%}
{% endfilter -%}
)
{% endblock %}