@autorest/python 6.28.4 → 6.29.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/autorest/m2r.py +50 -2
- package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +0 -10
- package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +1 -1
- package/generator/component-detection-pip-report.json +2 -2
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +0 -10
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +1 -1
- package/generator/pygen.egg-info/PKG-INFO +0 -1
- package/generator/pygen.egg-info/SOURCES.txt +0 -1
- package/generator/pygen.egg-info/requires.txt +0 -1
- package/generator/setup.py +0 -1
- package/package.json +2 -2
- package/requirements.txt +1 -0
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/generator/build/lib/pygen/m2r.py +0 -65
- package/generator/pygen/m2r.py +0 -65
package/autorest/m2r.py
CHANGED
|
@@ -5,12 +5,60 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
"""An autorest MD to RST plugin.
|
|
7
7
|
"""
|
|
8
|
-
|
|
8
|
+
import logging
|
|
9
|
+
from typing import Any, Dict, Set, Union
|
|
10
|
+
|
|
11
|
+
import m2r2
|
|
12
|
+
from pygen import YamlUpdatePlugin
|
|
9
13
|
|
|
10
|
-
from pygen.m2r import M2R
|
|
11
14
|
from . import YamlUpdatePluginAutorest
|
|
12
15
|
|
|
13
16
|
|
|
17
|
+
_LOGGER = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GeneratorRenderer(m2r2.RestRenderer):
|
|
21
|
+
"""Redefine the concept of inline HTML in the renderer, we don't want to define a new format
|
|
22
|
+
in the description/summary.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def inline_html(self, html: str) -> str:
|
|
26
|
+
"""Do not render inline HTML with a role definition."""
|
|
27
|
+
return r"\ :code:`{}`".format(html)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class M2R(YamlUpdatePlugin):
|
|
31
|
+
"""A plugin to convert any description and summary from MD to RST."""
|
|
32
|
+
|
|
33
|
+
def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
|
|
34
|
+
"""Convert in place the YAML str."""
|
|
35
|
+
self._convert_docstring_no_cycles(yaml_data, set())
|
|
36
|
+
|
|
37
|
+
def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
|
|
38
|
+
"""Walk the YAML tree to convert MD to RST."""
|
|
39
|
+
if id(yaml_data) in node_list:
|
|
40
|
+
return
|
|
41
|
+
node_list.add(id(yaml_data))
|
|
42
|
+
|
|
43
|
+
if isinstance(yaml_data, list):
|
|
44
|
+
for elt in yaml_data:
|
|
45
|
+
self._convert_docstring_no_cycles(elt, node_list)
|
|
46
|
+
elif isinstance(yaml_data, dict):
|
|
47
|
+
for key, value in yaml_data.items():
|
|
48
|
+
if key in ["description", "summary"]:
|
|
49
|
+
yaml_data[key] = self.convert_to_rst(value)
|
|
50
|
+
continue
|
|
51
|
+
self._convert_docstring_no_cycles(value, node_list)
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def convert_to_rst(string_to_convert: str) -> str:
|
|
55
|
+
"""Convert that string from MD to RST."""
|
|
56
|
+
try:
|
|
57
|
+
return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
|
|
58
|
+
except Exception: # pylint: disable=broad-except
|
|
59
|
+
return string_to_convert
|
|
60
|
+
|
|
61
|
+
|
|
14
62
|
class M2RAutorest(YamlUpdatePluginAutorest, M2R):
|
|
15
63
|
def get_options(self) -> Dict[str, Any]:
|
|
16
64
|
return {}
|
|
@@ -8,16 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
{{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
10
10
|
{% endif %}
|
|
11
|
-
{% if model.has_readonly_or_constant_property %}
|
|
12
|
-
|
|
13
|
-
Readonly variables are only populated by the server, and will be ignored when sending a request.
|
|
14
|
-
{% endif %}
|
|
15
|
-
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
16
|
-
|
|
17
|
-
{% if not model.is_usage_output %}
|
|
18
|
-
All required parameters must be populated in order to send to server.
|
|
19
|
-
{% endif %}
|
|
20
|
-
{% endif %}
|
|
21
11
|
|
|
22
12
|
{% if model.properties != None %}
|
|
23
13
|
{% for p in model.properties %}
|
|
@@ -410,7 +410,7 @@ class Model:
|
|
|
410
410
|
:param function key_extractors: A key extractor function.
|
|
411
411
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
412
412
|
:returns: An instance of this model
|
|
413
|
-
:raises
|
|
413
|
+
:raises DeserializationError: if something went wrong
|
|
414
414
|
:rtype: Self
|
|
415
415
|
"""
|
|
416
416
|
deserializer = Deserializer(cls._infer_class_models())
|
|
@@ -126,9 +126,9 @@
|
|
|
126
126
|
"implementation_version": "3.8.10",
|
|
127
127
|
"os_name": "posix",
|
|
128
128
|
"platform_machine": "x86_64",
|
|
129
|
-
"platform_release": "5.15.0-
|
|
129
|
+
"platform_release": "5.15.0-1081-azure",
|
|
130
130
|
"platform_system": "Linux",
|
|
131
|
-
"platform_version": "#
|
|
131
|
+
"platform_version": "#90~20.04.1-Ubuntu SMP Tue Jan 28 05:34:18 UTC 2025",
|
|
132
132
|
"python_full_version": "3.8.10",
|
|
133
133
|
"platform_python_implementation": "CPython",
|
|
134
134
|
"python_version": "3.8",
|
|
Binary file
|
|
@@ -8,16 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
{{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
10
10
|
{% endif %}
|
|
11
|
-
{% if model.has_readonly_or_constant_property %}
|
|
12
|
-
|
|
13
|
-
Readonly variables are only populated by the server, and will be ignored when sending a request.
|
|
14
|
-
{% endif %}
|
|
15
|
-
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
16
|
-
|
|
17
|
-
{% if not model.is_usage_output %}
|
|
18
|
-
All required parameters must be populated in order to send to server.
|
|
19
|
-
{% endif %}
|
|
20
|
-
{% endif %}
|
|
21
11
|
|
|
22
12
|
{% if model.properties != None %}
|
|
23
13
|
{% for p in model.properties %}
|
|
@@ -410,7 +410,7 @@ class Model:
|
|
|
410
410
|
:param function key_extractors: A key extractor function.
|
|
411
411
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
412
412
|
:returns: An instance of this model
|
|
413
|
-
:raises
|
|
413
|
+
:raises DeserializationError: if something went wrong
|
|
414
414
|
:rtype: Self
|
|
415
415
|
"""
|
|
416
416
|
deserializer = Deserializer(cls._infer_class_models())
|
package/generator/setup.py
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.29.1",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@typespec/http-client-python": "~0.
|
|
22
|
+
"@typespec/http-client-python": "~0.7.1",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
package/requirements.txt
CHANGED
|
Binary file
|
|
@@ -1,65 +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
|
-
"""An MD to RST plugin.
|
|
7
|
-
"""
|
|
8
|
-
import logging
|
|
9
|
-
from typing import Any, Dict, Set, Union
|
|
10
|
-
|
|
11
|
-
import m2r2
|
|
12
|
-
|
|
13
|
-
from . import YamlUpdatePlugin
|
|
14
|
-
from .utils import parse_args
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_LOGGER = logging.getLogger(__name__)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class GeneratorRenderer(m2r2.RestRenderer):
|
|
21
|
-
"""Redefine the concept of inline HTML in the renderer, we don't want to define a new format
|
|
22
|
-
in the description/summary.
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
def inline_html(self, html: str) -> str:
|
|
26
|
-
"""Do not render inline HTML with a role definition."""
|
|
27
|
-
return r"\ :code:`{}`".format(html)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class M2R(YamlUpdatePlugin):
|
|
31
|
-
"""A plugin to convert any description and summary from MD to RST."""
|
|
32
|
-
|
|
33
|
-
def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
|
|
34
|
-
"""Convert in place the YAML str."""
|
|
35
|
-
self._convert_docstring_no_cycles(yaml_data, set())
|
|
36
|
-
|
|
37
|
-
def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
|
|
38
|
-
"""Walk the YAML tree to convert MD to RST."""
|
|
39
|
-
if id(yaml_data) in node_list:
|
|
40
|
-
return
|
|
41
|
-
node_list.add(id(yaml_data))
|
|
42
|
-
|
|
43
|
-
if isinstance(yaml_data, list):
|
|
44
|
-
for elt in yaml_data:
|
|
45
|
-
self._convert_docstring_no_cycles(elt, node_list)
|
|
46
|
-
elif isinstance(yaml_data, dict):
|
|
47
|
-
for key, value in yaml_data.items():
|
|
48
|
-
if key in ["description", "summary"]:
|
|
49
|
-
yaml_data[key] = self.convert_to_rst(value)
|
|
50
|
-
continue
|
|
51
|
-
self._convert_docstring_no_cycles(value, node_list)
|
|
52
|
-
|
|
53
|
-
@staticmethod
|
|
54
|
-
def convert_to_rst(string_to_convert: str) -> str:
|
|
55
|
-
"""Convert that string from MD to RST."""
|
|
56
|
-
try:
|
|
57
|
-
return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
|
|
58
|
-
except Exception: # pylint: disable=broad-except
|
|
59
|
-
return string_to_convert
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if __name__ == "__main__":
|
|
63
|
-
# CADL pipeline will call this
|
|
64
|
-
args, unknown_args = parse_args()
|
|
65
|
-
M2R(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
|
package/generator/pygen/m2r.py
DELETED
|
@@ -1,65 +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
|
-
"""An MD to RST plugin.
|
|
7
|
-
"""
|
|
8
|
-
import logging
|
|
9
|
-
from typing import Any, Dict, Set, Union
|
|
10
|
-
|
|
11
|
-
import m2r2
|
|
12
|
-
|
|
13
|
-
from . import YamlUpdatePlugin
|
|
14
|
-
from .utils import parse_args
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_LOGGER = logging.getLogger(__name__)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class GeneratorRenderer(m2r2.RestRenderer):
|
|
21
|
-
"""Redefine the concept of inline HTML in the renderer, we don't want to define a new format
|
|
22
|
-
in the description/summary.
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
def inline_html(self, html: str) -> str:
|
|
26
|
-
"""Do not render inline HTML with a role definition."""
|
|
27
|
-
return r"\ :code:`{}`".format(html)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class M2R(YamlUpdatePlugin):
|
|
31
|
-
"""A plugin to convert any description and summary from MD to RST."""
|
|
32
|
-
|
|
33
|
-
def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
|
|
34
|
-
"""Convert in place the YAML str."""
|
|
35
|
-
self._convert_docstring_no_cycles(yaml_data, set())
|
|
36
|
-
|
|
37
|
-
def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
|
|
38
|
-
"""Walk the YAML tree to convert MD to RST."""
|
|
39
|
-
if id(yaml_data) in node_list:
|
|
40
|
-
return
|
|
41
|
-
node_list.add(id(yaml_data))
|
|
42
|
-
|
|
43
|
-
if isinstance(yaml_data, list):
|
|
44
|
-
for elt in yaml_data:
|
|
45
|
-
self._convert_docstring_no_cycles(elt, node_list)
|
|
46
|
-
elif isinstance(yaml_data, dict):
|
|
47
|
-
for key, value in yaml_data.items():
|
|
48
|
-
if key in ["description", "summary"]:
|
|
49
|
-
yaml_data[key] = self.convert_to_rst(value)
|
|
50
|
-
continue
|
|
51
|
-
self._convert_docstring_no_cycles(value, node_list)
|
|
52
|
-
|
|
53
|
-
@staticmethod
|
|
54
|
-
def convert_to_rst(string_to_convert: str) -> str:
|
|
55
|
-
"""Convert that string from MD to RST."""
|
|
56
|
-
try:
|
|
57
|
-
return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
|
|
58
|
-
except Exception: # pylint: disable=broad-except
|
|
59
|
-
return string_to_convert
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if __name__ == "__main__":
|
|
63
|
-
# CADL pipeline will call this
|
|
64
|
-
args, unknown_args = parse_args()
|
|
65
|
-
M2R(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
|