@autorest/python 6.0.0 → 6.1.1
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 +56 -0
- package/README.md +21 -2
- package/autorest/__init__.py +80 -14
- package/autorest/_utils.py +56 -0
- package/autorest/black/__init__.py +27 -14
- package/autorest/codegen/__init__.py +131 -90
- package/autorest/codegen/_utils.py +14 -0
- package/autorest/codegen/models/__init__.py +10 -1
- package/autorest/codegen/models/model_type.py +12 -1
- package/autorest/codegen/serializers/__init__.py +58 -58
- package/autorest/codegen/serializers/builder_serializer.py +1 -3
- package/autorest/codegen/serializers/client_serializer.py +6 -0
- package/autorest/codegen/templates/README.md.jinja2 +3 -3
- package/autorest/codegen/templates/setup.py.jinja2 +1 -2
- package/autorest/jsonrpc/server.py +13 -7
- package/autorest/m2r/__init__.py +18 -6
- package/autorest/m4reformatter/__init__.py +6 -3
- package/autorest/multiapi/__init__.py +57 -31
- package/autorest/multiapi/serializers/__init__.py +26 -24
- package/autorest/multiclient/__init__.py +50 -0
- package/autorest/multiclient/templates/init.py.jinja2 +8 -0
- package/autorest/multiclient/templates/version.py.jinja2 +8 -0
- package/autorest/postprocess/__init__.py +15 -12
- package/autorest/preprocess/__init__.py +24 -5
- package/autorest/preprocess/helpers.py +0 -30
- package/install.py +3 -3
- package/package.json +3 -2
- package/prepare.py +2 -2
- package/requirements.txt +8 -9
- package/run-python3.js +2 -2
- package/run_cadl.py +26 -0
- package/setup.py +2 -3
- package/start.py +2 -2
- package/autorest/multiapi/serializers/multiapi_serializer.py +0 -114
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# -------------------------------------------------------------------------
|
|
2
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
-
# license information.
|
|
5
|
-
# --------------------------------------------------------------------------
|
|
6
|
-
from typing import Any, Dict
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from jinja2 import Environment, PackageLoader
|
|
9
|
-
|
|
10
|
-
from ...jsonrpc import AutorestAPI
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class MultiAPISerializer:
|
|
14
|
-
def __init__(
|
|
15
|
-
self,
|
|
16
|
-
conf: Dict[str, Any],
|
|
17
|
-
async_mode: bool,
|
|
18
|
-
autorestapi: AutorestAPI,
|
|
19
|
-
service_client_filename: str,
|
|
20
|
-
):
|
|
21
|
-
self.conf = conf
|
|
22
|
-
self.async_mode = async_mode
|
|
23
|
-
self._autorestapi = autorestapi
|
|
24
|
-
self.service_client_filename = service_client_filename
|
|
25
|
-
self.env = Environment(
|
|
26
|
-
loader=PackageLoader("autorest.multiapi", "templates"),
|
|
27
|
-
keep_trailing_newline=True,
|
|
28
|
-
line_statement_prefix="##",
|
|
29
|
-
line_comment_prefix="###",
|
|
30
|
-
trim_blocks=True,
|
|
31
|
-
lstrip_blocks=True,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
def _get_file_path(self, filename: str) -> Path:
|
|
35
|
-
if self.async_mode:
|
|
36
|
-
return Path("aio") / filename
|
|
37
|
-
return Path(filename)
|
|
38
|
-
|
|
39
|
-
def serialize(self):
|
|
40
|
-
self._autorestapi.write_file(
|
|
41
|
-
self._get_file_path("__init__.py"), self.serialize_multiapi_init()
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
service_client_filename_with_py_extension = self.service_client_filename + ".py"
|
|
45
|
-
self._autorestapi.write_file(
|
|
46
|
-
self._get_file_path(service_client_filename_with_py_extension),
|
|
47
|
-
self.serialize_multiapi_client(),
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
configuration_filename = "_configuration.py"
|
|
51
|
-
self._autorestapi.write_file(
|
|
52
|
-
self._get_file_path(configuration_filename),
|
|
53
|
-
self.serialize_multiapi_config(),
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
operation_mixins_filename = "_operations_mixin.py"
|
|
57
|
-
if self.conf["mixin_operations"]:
|
|
58
|
-
self._autorestapi.write_file(
|
|
59
|
-
self._get_file_path(operation_mixins_filename),
|
|
60
|
-
self.serialize_multiapi_operation_mixins(),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
if self._autorestapi.read_file("_version.py"):
|
|
64
|
-
self._autorestapi.write_file(
|
|
65
|
-
"_version.py", self._autorestapi.read_file("_version.py")
|
|
66
|
-
)
|
|
67
|
-
elif self._autorestapi.read_file("version.py"):
|
|
68
|
-
self._autorestapi.write_file(
|
|
69
|
-
"_version.py", self._autorestapi.read_file("version.py")
|
|
70
|
-
)
|
|
71
|
-
else:
|
|
72
|
-
self._autorestapi.write_file(
|
|
73
|
-
Path("_version.py"), self.serialize_multiapi_version()
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
# don't erase patch file
|
|
77
|
-
if self._autorestapi.read_file("_patch.py"):
|
|
78
|
-
self._autorestapi.write_file(
|
|
79
|
-
"_patch.py", self._autorestapi.read_file("_patch.py")
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
self._autorestapi.write_file(
|
|
83
|
-
Path("models.py"), self.serialize_multiapi_models()
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
self._autorestapi.write_file(Path("py.typed"), "# Marker file for PEP 561.")
|
|
87
|
-
|
|
88
|
-
def serialize_multiapi_init(self) -> str:
|
|
89
|
-
template = self.env.get_template("multiapi_init.py.jinja2")
|
|
90
|
-
return template.render(
|
|
91
|
-
service_client_filename=self.service_client_filename,
|
|
92
|
-
client_name=self.conf["client_name"],
|
|
93
|
-
async_mode=self.async_mode,
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
def serialize_multiapi_client(self) -> str:
|
|
97
|
-
template = self.env.get_template("multiapi_service_client.py.jinja2")
|
|
98
|
-
return template.render(**self.conf, async_mode=self.async_mode)
|
|
99
|
-
|
|
100
|
-
def serialize_multiapi_config(self) -> str:
|
|
101
|
-
template = self.env.get_template("multiapi_config.py.jinja2")
|
|
102
|
-
return template.render(**self.conf, async_mode=self.async_mode)
|
|
103
|
-
|
|
104
|
-
def serialize_multiapi_models(self) -> str:
|
|
105
|
-
template = self.env.get_template("multiapi_models.py.jinja2")
|
|
106
|
-
return template.render(**self.conf)
|
|
107
|
-
|
|
108
|
-
def serialize_multiapi_version(self) -> str:
|
|
109
|
-
template = self.env.get_template("multiapi_version.py.jinja2")
|
|
110
|
-
return template.render()
|
|
111
|
-
|
|
112
|
-
def serialize_multiapi_operation_mixins(self) -> str:
|
|
113
|
-
template = self.env.get_template("multiapi_operations_mixin.py.jinja2")
|
|
114
|
-
return template.render(**self.conf, async_mode=self.async_mode)
|