@autorest/python 6.0.0-rc.1 → 6.1.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.
Files changed (35) hide show
  1. package/ChangeLog.md +60 -2
  2. package/README.md +21 -2
  3. package/autorest/__init__.py +80 -14
  4. package/autorest/_utils.py +56 -0
  5. package/autorest/black/__init__.py +27 -14
  6. package/autorest/codegen/__init__.py +131 -90
  7. package/autorest/codegen/_utils.py +14 -0
  8. package/autorest/codegen/models/__init__.py +10 -1
  9. package/autorest/codegen/models/model_type.py +12 -1
  10. package/autorest/codegen/models/paging_operation.py +15 -1
  11. package/autorest/codegen/serializers/__init__.py +58 -58
  12. package/autorest/codegen/serializers/builder_serializer.py +26 -5
  13. package/autorest/codegen/serializers/client_serializer.py +6 -0
  14. package/autorest/codegen/templates/README.md.jinja2 +3 -3
  15. package/autorest/codegen/templates/serialization.py.jinja2 +3 -3
  16. package/autorest/codegen/templates/setup.py.jinja2 +2 -3
  17. package/autorest/jsonrpc/server.py +13 -7
  18. package/autorest/m2r/__init__.py +18 -6
  19. package/autorest/m4reformatter/__init__.py +6 -3
  20. package/autorest/multiapi/__init__.py +57 -31
  21. package/autorest/multiapi/serializers/__init__.py +26 -24
  22. package/autorest/multiclient/__init__.py +50 -0
  23. package/autorest/multiclient/templates/init.py.jinja2 +8 -0
  24. package/autorest/multiclient/templates/version.py.jinja2 +8 -0
  25. package/autorest/postprocess/__init__.py +15 -12
  26. package/autorest/preprocess/__init__.py +47 -8
  27. package/autorest/preprocess/helpers.py +0 -30
  28. package/install.py +3 -3
  29. package/package.json +2 -2
  30. package/prepare.py +2 -2
  31. package/requirements.txt +8 -9
  32. package/run-python3.js +2 -2
  33. package/setup.py +2 -3
  34. package/start.py +2 -2
  35. package/autorest/multiapi/serializers/multiapi_serializer.py +0 -114
package/run-python3.js CHANGED
@@ -9,8 +9,8 @@
9
9
  const cp = require("child_process");
10
10
  const extension = require("@autorest/system-requirements");
11
11
 
12
- async function runPython3(scriptName, debug = "") {
13
- const command = await extension.patchPythonPath(["python", scriptName, debug], { version: ">=3.6", environmentVariable: "AUTOREST_PYTHON_EXE" });
12
+ async function runPython3(scriptName, ...args) {
13
+ const command = await extension.patchPythonPath(["python", scriptName, ...args], { version: ">=3.7", environmentVariable: "AUTOREST_PYTHON_EXE" });
14
14
  cp.execSync(command.join(" "), {
15
15
  stdio: [0, 1, 2]
16
16
  });
package/setup.py CHANGED
@@ -36,7 +36,6 @@ setup(
36
36
  'Development Status :: 4 - Beta',
37
37
  'Programming Language :: Python',
38
38
  'Programming Language :: Python :: 3',
39
- 'Programming Language :: Python :: 3.6',
40
39
  'Programming Language :: Python :: 3.7',
41
40
  'Programming Language :: Python :: 3.8',
42
41
  'License :: OSI Approved :: MIT License',
@@ -48,8 +47,8 @@ setup(
48
47
  "json-rpc",
49
48
  "Jinja2 >= 2.11", # I need "include" and auto-context + blank line are not indented by default
50
49
  "pyyaml",
51
- "mistune < 2.0.0", # Need to pin mistune's max version so m2r doesn't break
52
- "m2r",
50
+ "m2r2",
53
51
  "black",
52
+ "docutils<0.19", # m2r2 fails with docutils 0.19
54
53
  ],
55
54
  )
package/start.py CHANGED
@@ -6,8 +6,8 @@
6
6
  # license information.
7
7
  # --------------------------------------------------------------------------
8
8
  import sys
9
- if not sys.version_info >= (3, 6, 0):
10
- raise Exception("Autorest for Python extension requires Python 3.6 at least")
9
+ if not sys.version_info >= (3, 7, 0):
10
+ raise Exception("Autorest for Python extension requires Python 3.7 at least")
11
11
 
12
12
  from pathlib import Path
13
13
  import venv
@@ -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)