@autorest/python 6.9.7 → 6.9.8
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
-
from typing import Dict, Any, Union
|
|
7
|
+
from typing import Dict, Any, Union, Optional
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
import yaml
|
|
10
10
|
|
|
@@ -150,6 +150,28 @@ class OptionsRetriever:
|
|
|
150
150
|
# Force some options in ARM MODE
|
|
151
151
|
return True if self.azure_arm else head_as_boolean
|
|
152
152
|
|
|
153
|
+
@property
|
|
154
|
+
def package_mode(self) -> str:
|
|
155
|
+
return self.options.get("packaging-files-dir") or self.options.get(
|
|
156
|
+
"package-mode", ""
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def packaging_files_config(self) -> Optional[Dict[str, Any]]:
|
|
161
|
+
packaging_files_config = self.options.get("packaging-files-config")
|
|
162
|
+
if packaging_files_config is None:
|
|
163
|
+
return None
|
|
164
|
+
# packaging-files-config is either a string or a dict
|
|
165
|
+
# if it's a string, we can split on the comma to get the dict
|
|
166
|
+
# otherwise we just return
|
|
167
|
+
try:
|
|
168
|
+
return {
|
|
169
|
+
k.strip(): v.strip()
|
|
170
|
+
for k, v in [i.split(":") for i in packaging_files_config.split("|")]
|
|
171
|
+
}
|
|
172
|
+
except AttributeError:
|
|
173
|
+
return packaging_files_config
|
|
174
|
+
|
|
153
175
|
|
|
154
176
|
class CodeGenerator(Plugin):
|
|
155
177
|
def __init__(self, *args, **kwargs: Any) -> None:
|
|
@@ -273,7 +295,6 @@ class CodeGenerator(Plugin):
|
|
|
273
295
|
break
|
|
274
296
|
|
|
275
297
|
def _build_code_model_options(self) -> Dict[str, Any]:
|
|
276
|
-
"""Build en options dict from the user input while running autorest."""
|
|
277
298
|
flags = [
|
|
278
299
|
"azure_arm",
|
|
279
300
|
"head_as_boolean",
|
|
@@ -298,7 +319,7 @@ class CodeGenerator(Plugin):
|
|
|
298
319
|
"combine_operation_files",
|
|
299
320
|
"package_mode",
|
|
300
321
|
"package_pprint_name",
|
|
301
|
-
"
|
|
322
|
+
"packaging_files_config",
|
|
302
323
|
"default_optional_constants_to_none",
|
|
303
324
|
"generate_sample",
|
|
304
325
|
"default_api_version",
|
|
@@ -397,7 +418,7 @@ class CodeGeneratorAutorest(CodeGenerator, PluginAutorest):
|
|
|
397
418
|
),
|
|
398
419
|
"package-mode": self._autorestapi.get_value("package-mode"),
|
|
399
420
|
"package-pprint-name": self._autorestapi.get_value("package-pprint-name"),
|
|
400
|
-
"
|
|
421
|
+
"packaging-files-config": self._autorestapi.get_value(
|
|
401
422
|
"package-configuration"
|
|
402
423
|
),
|
|
403
424
|
"default-optional-constants-to-none": self._autorestapi.get_boolean_value(
|
|
@@ -238,7 +238,7 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
|
|
|
238
238
|
else:
|
|
239
239
|
return
|
|
240
240
|
serializer = GeneralSerializer(self.code_model, env, async_mode=False)
|
|
241
|
-
params = self.code_model.options["
|
|
241
|
+
params = self.code_model.options["packaging_files_config"] or {}
|
|
242
242
|
for template_name in package_files:
|
|
243
243
|
if (
|
|
244
244
|
self.code_model.options["unbranded"]
|