@autorest/python 5.11.2 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +26 -0
- package/autorest/codegen/__init__.py +5 -5
- package/autorest/codegen/models/client.py +2 -2
- package/autorest/codegen/models/code_model.py +5 -1
- package/autorest/codegen/models/operation_group.py +5 -3
- package/autorest/codegen/models/parameter.py +4 -3
- package/autorest/codegen/models/parameter_list.py +30 -26
- package/autorest/codegen/models/request_builder.py +5 -1
- package/autorest/codegen/models/request_builder_parameter.py +4 -3
- package/autorest/codegen/models/request_builder_parameter_list.py +15 -6
- package/autorest/codegen/models/rest.py +3 -2
- package/autorest/codegen/serializers/__init__.py +48 -48
- package/autorest/codegen/serializers/builder_serializer.py +32 -27
- package/autorest/codegen/serializers/client_serializer.py +37 -9
- package/autorest/codegen/serializers/general_serializer.py +7 -5
- package/autorest/codegen/serializers/import_serializer.py +6 -6
- package/autorest/codegen/serializers/metadata_serializer.py +2 -2
- package/autorest/codegen/serializers/model_base_serializer.py +3 -3
- package/autorest/codegen/serializers/model_generic_serializer.py +1 -1
- package/autorest/codegen/serializers/model_python3_serializer.py +1 -1
- package/autorest/codegen/serializers/{operation_group_serializer.py → operation_groups_serializer.py} +27 -29
- package/autorest/codegen/serializers/operations_init_serializer.py +34 -2
- package/autorest/codegen/serializers/patch_serializer.py +15 -0
- package/autorest/codegen/serializers/rest_serializer.py +9 -4
- package/autorest/codegen/serializers/utils.py +2 -2
- package/autorest/codegen/templates/config.py.jinja2 +1 -11
- package/autorest/codegen/templates/init.py.jinja2 +4 -5
- package/autorest/codegen/templates/metadata.json.jinja2 +2 -2
- package/autorest/codegen/templates/model_init.py.jinja2 +1 -1
- package/autorest/codegen/templates/{operations_class.py.jinja2 → operation_group.py.jinja2} +2 -0
- package/autorest/codegen/templates/{operations_container.py.jinja2 → operation_groups_container.py.jinja2} +7 -21
- package/autorest/codegen/templates/operations_folder_init.py.jinja2 +13 -0
- package/autorest/codegen/templates/patch.py.jinja2 +31 -0
- package/autorest/codegen/templates/request_builder.py.jinja2 +7 -2
- package/autorest/codegen/templates/request_builders.py.jinja2 +1 -1
- package/autorest/codegen/templates/setup.py.jinja2 +1 -1
- package/autorest/multiapi/serializers/__init__.py +3 -3
- package/autorest/multiapi/serializers/import_serializer.py +5 -5
- package/autorest/namer/name_converter.py +1 -0
- package/package.json +2 -2
- package/setup.py +1 -0
- package/autorest/codegen/templates/operations_class_mixin.py.jinja2 +0 -16
- package/autorest/codegen/templates/operations_container_init.py.jinja2 +0 -24
- package/autorest/codegen/templates/operations_container_mixin.py.jinja2 +0 -21
- package/autorest/codegen/templates/operations_init.py.jinja2 +0 -26
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
3
3
|
{% set version_import = ".._version" if async_mode else "._version" %}
|
|
4
|
-
{% macro method_signature() %}
|
|
5
|
-
def __init__(
|
|
6
|
-
self,
|
|
7
|
-
{% for param_signature in code_model.global_parameters.config_method_signature(async_mode) %}
|
|
8
|
-
{{ param_signature }}
|
|
9
|
-
{% endfor %}
|
|
10
|
-
){{" -> None" if async_mode else "" }}:{% endmacro %}
|
|
11
4
|
{# actual template starts here #}
|
|
12
5
|
# coding=utf-8
|
|
13
6
|
{{ code_model.options['license_header'] }}
|
|
@@ -32,10 +25,7 @@ class {{ code_model.class_name }}Configuration(Configuration):
|
|
|
32
25
|
{% endfor %}
|
|
33
26
|
"""
|
|
34
27
|
|
|
35
|
-
{{
|
|
36
|
-
{% if not async_mode %}
|
|
37
|
-
# type: (...) -> None
|
|
38
|
-
{% endif %}
|
|
28
|
+
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
39
29
|
super({{ code_model.class_name }}Configuration, self).__init__(**kwargs)
|
|
40
30
|
{% if code_model.service_client.parameters.config_kwargs_to_pop(async_mode) %}
|
|
41
31
|
{{ op_tools.serialize(serializer.pop_kwargs_from_signature(async_mode)) | indent(8) }}
|
|
@@ -9,8 +9,7 @@ __version__ = VERSION
|
|
|
9
9
|
{% endif %}
|
|
10
10
|
__all__ = ['{{ code_model.class_name }}']
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
pass
|
|
12
|
+
# `._patch.py` is used for handwritten extensions to the generated code
|
|
13
|
+
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
|
|
14
|
+
from ._patch import patch_sdk
|
|
15
|
+
patch_sdk()
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sync": {
|
|
21
21
|
{% for gp in sync_global_parameters.config_method %}
|
|
22
22
|
{{ gp.serialized_name | tojson }}: {
|
|
23
|
-
"signature": {{ gp.method_signature(
|
|
23
|
+
"signature": {{ gp.method_signature(is_python3_file=False) | tojson }},
|
|
24
24
|
"description": {{ gp.description | tojson }},
|
|
25
25
|
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
26
26
|
"required": {{ gp.required | tojson }}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"async": {
|
|
31
31
|
{% for gp in async_global_parameters.config_method %}
|
|
32
32
|
{{ gp.serialized_name | tojson }}: {
|
|
33
|
-
"signature": {{ (gp.method_signature(
|
|
33
|
+
"signature": {{ (gp.method_signature(is_python3_file=True)) | tojson }},
|
|
34
34
|
"description": {{ gp.description | tojson }},
|
|
35
35
|
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
36
36
|
"required": {{ gp.required | tojson }}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
class {{ operation_group.class_name }}{{ object_base_class }}:
|
|
2
|
+
{% if not operation_group.is_empty_operation_group %}
|
|
2
3
|
"""{{ operation_group.class_name }} {{ operations_description }}.
|
|
3
4
|
|
|
4
5
|
You should not instantiate this class directly. Instead, you should create a Client instance that
|
|
@@ -23,6 +24,7 @@ class {{ operation_group.class_name }}{{ object_base_class }}:
|
|
|
23
24
|
self._serialize = serializer
|
|
24
25
|
self._deserialize = deserializer
|
|
25
26
|
self._config = config
|
|
27
|
+
{% endif %}
|
|
26
28
|
{% for operation in operation_group.operations %}
|
|
27
29
|
|
|
28
30
|
{% set request_builder = operation.request_builder %}
|
|
@@ -2,39 +2,25 @@
|
|
|
2
2
|
{% set object_base_class = "" if async_mode else "(object)" %}
|
|
3
3
|
{% set operations_description = "async operations" if async_mode else "operations" %}
|
|
4
4
|
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
5
|
-
{% set operation_group = operation_groups[0] %}
|
|
6
5
|
# coding=utf-8
|
|
7
6
|
{{ code_model.options['license_header'] }}
|
|
8
7
|
{{ imports }}
|
|
9
8
|
|
|
10
9
|
{% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
|
|
11
10
|
{{ op_tools.declare_serializer(code_model) }}
|
|
12
|
-
{%- if not
|
|
11
|
+
{%- if not is_python3_file %}
|
|
13
12
|
# fmt: off
|
|
14
13
|
{% endif %}
|
|
15
|
-
{%
|
|
14
|
+
{% for operation_group in operation_groups %}
|
|
16
15
|
{% for request_builder in code_model.rest.request_builders | selectattr("operation_group_name", "equalto", operation_group.name) %}
|
|
17
16
|
|
|
18
17
|
{% include "request_builder.py.jinja2" %}
|
|
19
18
|
{% endfor %}
|
|
20
|
-
{%
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{% include "request_builder.py.jinja2" %}
|
|
24
|
-
{% endfor %}
|
|
25
|
-
{% endif %}
|
|
26
|
-
{% if not is_python_3_file %}
|
|
19
|
+
{% endfor %}
|
|
20
|
+
{% if not is_python3_file %}
|
|
27
21
|
# fmt: on
|
|
28
22
|
{% endif %}
|
|
29
23
|
{% endif %}
|
|
30
|
-
{%
|
|
31
|
-
{% include "
|
|
32
|
-
{%
|
|
33
|
-
{% for operation_group in operation_groups %}
|
|
34
|
-
{% if operation_group.is_empty_operation_group %}
|
|
35
|
-
{% include "operations_class_mixin.py.jinja2" %}
|
|
36
|
-
{% else %}
|
|
37
|
-
{% include "operations_class.py.jinja2" %}
|
|
38
|
-
{% endif %}
|
|
39
|
-
{% endfor %}
|
|
40
|
-
{% endif %}
|
|
24
|
+
{% for operation_group in operation_groups %}
|
|
25
|
+
{% include "operation_group.py.jinja2" %}
|
|
26
|
+
{% endfor %}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
|
+
{# actual template starts here #}
|
|
3
|
+
# coding=utf-8
|
|
4
|
+
{{ code_model.options['license_header'] }}
|
|
5
|
+
|
|
6
|
+
{{ op_tools.serialize(operation_group_imports()) }}
|
|
7
|
+
{% if operation_groups %}
|
|
8
|
+
__all__ = [
|
|
9
|
+
{% for operation_group in operation_groups %}
|
|
10
|
+
'{{ operation_group.class_name }}',
|
|
11
|
+
{% endfor %}
|
|
12
|
+
]
|
|
13
|
+
{% endif %}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
#
|
|
6
|
+
# The MIT License (MIT)
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
# of this software and associated documentation files (the ""Software""), to
|
|
10
|
+
# deal in the Software without restriction, including without limitation the
|
|
11
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
12
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
# furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
|
16
|
+
# all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
|
+
# IN THE SOFTWARE.
|
|
25
|
+
#
|
|
26
|
+
# --------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
# This file is used for handwritten extensions to the generated code. Example:
|
|
29
|
+
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
|
|
30
|
+
def patch_sdk():
|
|
31
|
+
pass
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{% if code_model.options["builders_visibility"] == "public" %}
|
|
5
5
|
{{ op_tools.description(request_builder, request_builder_serializer) | indent }}
|
|
6
6
|
{% endif %}
|
|
7
|
-
{% if request_builder.parameters.kwargs_to_pop(
|
|
7
|
+
{% if request_builder.parameters.kwargs_to_pop(is_python3_file) %}
|
|
8
8
|
{{ op_tools.serialize(request_builder_serializer.pop_kwargs_from_signature(request_builder)) | indent }}
|
|
9
9
|
{% endif %}
|
|
10
10
|
{% if request_builder.parameters.constant|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code")|selectattr("in_method_signature", "equalto", False) %}
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
{% endfor %}
|
|
14
14
|
{% endif %}
|
|
15
15
|
# Construct URL
|
|
16
|
-
|
|
16
|
+
{% if code_model.options["version_tolerant"] or code_model.options["low_level_client"] %}
|
|
17
|
+
{% set url_value = keywords.escape_str(request_builder.url) %}
|
|
18
|
+
{% else %}
|
|
19
|
+
{% set url_value = 'kwargs.pop("template_url", ' + keywords.escape_str(request_builder.url) + ')' %}
|
|
20
|
+
{% endif %}
|
|
21
|
+
url = {{ url_value }}
|
|
17
22
|
{% if request_builder.parameters.path %}
|
|
18
23
|
{{ op_tools.serialize(request_builder_serializer.serialize_path(request_builder)) | indent }}
|
|
19
24
|
url = _format_url_section(url, **path_format_arguments)
|
|
@@ -16,7 +16,7 @@ VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}"
|
|
|
16
16
|
# prerequisite: setuptools
|
|
17
17
|
# http://pypi.python.org/pypi/setuptools
|
|
18
18
|
|
|
19
|
-
REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.20.
|
|
19
|
+
REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.20.1"{{ azure_mgmt_core_import }}]
|
|
20
20
|
|
|
21
21
|
setup(
|
|
22
22
|
name=NAME,
|
|
@@ -55,7 +55,7 @@ class MultiAPISerializer(object):
|
|
|
55
55
|
# serialize service client file
|
|
56
56
|
imports = FileImportSerializer(
|
|
57
57
|
code_model.service_client.imports(async_mode),
|
|
58
|
-
|
|
58
|
+
is_python3_file=async_mode
|
|
59
59
|
)
|
|
60
60
|
self._autorestapi.write_file(
|
|
61
61
|
_get_file_path(code_model.service_client.filename, async_mode),
|
|
@@ -65,7 +65,7 @@ class MultiAPISerializer(object):
|
|
|
65
65
|
# serialize config file
|
|
66
66
|
imports = FileImportSerializer(
|
|
67
67
|
code_model.config.imports(async_mode),
|
|
68
|
-
|
|
68
|
+
is_python3_file=async_mode
|
|
69
69
|
)
|
|
70
70
|
self._autorestapi.write_file(
|
|
71
71
|
_get_file_path("_configuration", async_mode),
|
|
@@ -76,7 +76,7 @@ class MultiAPISerializer(object):
|
|
|
76
76
|
if code_model.operation_mixin_group.mixin_operations:
|
|
77
77
|
imports = FileImportSerializer(
|
|
78
78
|
code_model.operation_mixin_group.imports(async_mode),
|
|
79
|
-
|
|
79
|
+
is_python3_file=async_mode
|
|
80
80
|
)
|
|
81
81
|
self._autorestapi.write_file(
|
|
82
82
|
_get_file_path("_operations_mixin", async_mode),
|
|
@@ -36,9 +36,9 @@ def _get_import_clauses(imports: Dict[ImportType, Dict[str, Set[Optional[str]]]]
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
class FileImportSerializer:
|
|
39
|
-
def __init__(self, file_import: FileImport,
|
|
39
|
+
def __init__(self, file_import: FileImport, is_python3_file: bool) -> None:
|
|
40
40
|
self._file_import = file_import
|
|
41
|
-
self.
|
|
41
|
+
self.is_python3_file = is_python3_file
|
|
42
42
|
|
|
43
43
|
def _switch_typing_section_key(self, new_key: TypingSection):
|
|
44
44
|
switched_dictionary = {}
|
|
@@ -60,7 +60,7 @@ class FileImportSerializer:
|
|
|
60
60
|
def _add_type_checking_import(self):
|
|
61
61
|
if (
|
|
62
62
|
self._file_import.imports.get(TypingSection.TYPING) or
|
|
63
|
-
(not self.
|
|
63
|
+
(not self.is_python3_file and self._file_import.imports.get(TypingSection.CONDITIONAL))
|
|
64
64
|
):
|
|
65
65
|
self._file_import.add_from_import("typing", "TYPE_CHECKING", ImportType.STDLIB)
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@ class FileImportSerializer:
|
|
|
68
68
|
self._add_type_checking_import()
|
|
69
69
|
regular_imports = ""
|
|
70
70
|
regular_imports_dict = self._get_imports_dict(
|
|
71
|
-
baseline_typing_section=TypingSection.REGULAR, add_conditional_typing=self.
|
|
71
|
+
baseline_typing_section=TypingSection.REGULAR, add_conditional_typing=self.is_python3_file
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
if regular_imports_dict:
|
|
@@ -78,7 +78,7 @@ class FileImportSerializer:
|
|
|
78
78
|
|
|
79
79
|
typing_imports = ""
|
|
80
80
|
typing_imports_dict = self._get_imports_dict(
|
|
81
|
-
baseline_typing_section=TypingSection.TYPING, add_conditional_typing=not self.
|
|
81
|
+
baseline_typing_section=TypingSection.TYPING, add_conditional_typing=not self.is_python3_file
|
|
82
82
|
)
|
|
83
83
|
if typing_imports_dict:
|
|
84
84
|
typing_imports += "\n\nif TYPE_CHECKING:\n # pylint: disable=unused-import,ungrouped-imports\n "
|
|
@@ -71,6 +71,7 @@ class NameConverter:
|
|
|
71
71
|
operation_group_name = operation_group['language']['default']['name']
|
|
72
72
|
if not operation_group_name:
|
|
73
73
|
operation_group['language']['python']['className'] = code_model_title + "OperationsMixin"
|
|
74
|
+
operation_group['language']['python']['name'] = ""
|
|
74
75
|
elif operation_group_name == 'Operations':
|
|
75
76
|
operation_group['language']['python']['className'] = operation_group_name
|
|
76
77
|
else:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "node run-python3.js prepare.py",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@azure-tools/extension": "~3.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@microsoft.azure/autorest.testserver": "^3.1.
|
|
30
|
+
"@microsoft.azure/autorest.testserver": "^3.1.8"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"autorest/**/*.py",
|
package/setup.py
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class {{ operation_group.class_name }}{{ object_base_class }}:
|
|
2
|
-
{% for operation in operation_group.operations %}
|
|
3
|
-
|
|
4
|
-
{% set request_builder = operation.request_builder %}
|
|
5
|
-
{% set operation_serializer = get_operation_serializer(operation) %}
|
|
6
|
-
{% if is_lro(operation) and is_paging(operation) %}
|
|
7
|
-
{%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %}
|
|
8
|
-
{% elif is_lro(operation) %}
|
|
9
|
-
{%- macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %}
|
|
10
|
-
{% elif is_paging(operation) %}
|
|
11
|
-
{% macro someop() %}{% include "paging_operation.py.jinja2" %}{% endmacro %}
|
|
12
|
-
{% else %}
|
|
13
|
-
{% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %}
|
|
14
|
-
{% endif %}
|
|
15
|
-
{{ someop()|indent }}
|
|
16
|
-
{% endfor %}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{% macro operation_group_imports(filename_suffix="") %}
|
|
2
|
-
{% for operation_group in operation_groups %}
|
|
3
|
-
from .{{ ("_operations" if code_model.options['combine_operation_files'] else operation_group.filename) + filename_suffix }} import {{ operation_group.class_name }}
|
|
4
|
-
{% endfor %}
|
|
5
|
-
{% endmacro %}
|
|
6
|
-
{# actual template starts here #}
|
|
7
|
-
# coding=utf-8
|
|
8
|
-
{{ code_model.options['license_header'] }}
|
|
9
|
-
|
|
10
|
-
{% if not code_model.options["add_python_3_operation_files"] %}
|
|
11
|
-
{{ operation_group_imports() }}
|
|
12
|
-
{% elif code_model.options["add_python_3_operation_files"] and code_model.options["python_3_only"] %}
|
|
13
|
-
{{ operation_group_imports("_py3") }}
|
|
14
|
-
{% else %}
|
|
15
|
-
try:
|
|
16
|
-
{{ operation_group_imports("_py3") | indent }}
|
|
17
|
-
except (SyntaxError, ImportError):
|
|
18
|
-
{{ operation_group_imports() | indent }}
|
|
19
|
-
{% endif %}
|
|
20
|
-
__all__ = [
|
|
21
|
-
{% for operation_group in operation_groups %}
|
|
22
|
-
'{{ operation_group.class_name }}',
|
|
23
|
-
{% endfor %}
|
|
24
|
-
]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
|
-
{% set object_base_class = "" if async_mode else "(object)" %}
|
|
3
|
-
{% set operation_group = operation_groups[0] %}
|
|
4
|
-
# coding=utf-8
|
|
5
|
-
{{ code_model.options['license_header'] }}
|
|
6
|
-
{{ imports }}
|
|
7
|
-
|
|
8
|
-
{% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
|
|
9
|
-
{{ op_tools.declare_serializer(code_model) }}
|
|
10
|
-
{%- if not is_python_3_file %}
|
|
11
|
-
# fmt: off
|
|
12
|
-
{% endif %}
|
|
13
|
-
{% for request_builder in code_model.rest.request_builders | selectattr("builder_group_name", "equalto", "") %}
|
|
14
|
-
|
|
15
|
-
{% include "request_builder.py.jinja2" %}
|
|
16
|
-
{% endfor %}
|
|
17
|
-
{% if not is_python_3_file %}
|
|
18
|
-
# fmt: on
|
|
19
|
-
{% endif %}
|
|
20
|
-
{% endif %}
|
|
21
|
-
{% include "operations_class_mixin.py.jinja2" %}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{% macro operation_group_imports(filename_suffix="") %}
|
|
2
|
-
{% for operation_group in operation_groups %}
|
|
3
|
-
from .{{ operation_group.filename + filename_suffix }} import {{ operation_group.class_name }}
|
|
4
|
-
{% endfor %}
|
|
5
|
-
{% endmacro %}
|
|
6
|
-
{# actual template starts here #}
|
|
7
|
-
# coding=utf-8
|
|
8
|
-
{{ code_model.options['license_header'] }}
|
|
9
|
-
|
|
10
|
-
{% if not code_model.options["add_python_3_operation_files"] %}
|
|
11
|
-
{{ operation_group_imports() }}
|
|
12
|
-
{% elif code_model.options["add_python_3_operation_files"] and code_model.options["python_3_only"] %}
|
|
13
|
-
{{ operation_group_imports("_py3") }}
|
|
14
|
-
{% else %}
|
|
15
|
-
try:
|
|
16
|
-
{{ operation_group_imports("_py3") | indent }}
|
|
17
|
-
except (SyntaxError, ImportError):
|
|
18
|
-
{{ operation_group_imports() | indent }}
|
|
19
|
-
{% endif %}
|
|
20
|
-
{% if operation_groups %}
|
|
21
|
-
__all__ = [
|
|
22
|
-
{% for operation_group in operation_groups %}
|
|
23
|
-
'{{ operation_group.class_name }}',
|
|
24
|
-
{% endfor %}
|
|
25
|
-
]
|
|
26
|
-
{% endif %}
|