@typespec/http-client-python 0.6.1 → 0.6.2
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/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
- package/generator/build/lib/pygen/black.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +19 -3
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/black.py +1 -1
- package/generator/pygen/codegen/serializers/__init__.py +19 -3
- package/package.json +1 -1
|
Binary file
|
|
@@ -60,7 +60,7 @@ class BlackScriptPlugin(Plugin):
|
|
|
60
60
|
except:
|
|
61
61
|
_LOGGER.error("Error: failed to format %s", file)
|
|
62
62
|
raise
|
|
63
|
-
if len(file_content.splitlines()) > 1000:
|
|
63
|
+
if len(file_content.splitlines()) > 1000 and "pylint: disable=too-many-lines" not in file_content:
|
|
64
64
|
file_content = "# pylint: disable=too-many-lines\n" + file_content
|
|
65
65
|
self.write_file(file, file_content)
|
|
66
66
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
7
|
from collections import namedtuple
|
|
8
|
+
import re
|
|
8
9
|
from typing import List, Any, Union
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from jinja2 import PackageLoader, Environment, FileSystemLoader, StrictUndefined
|
|
@@ -94,6 +95,19 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
94
95
|
async_loop = AsyncInfo(async_mode=True, async_path="aio/")
|
|
95
96
|
return [sync_loop, async_loop] if self.has_aio_folder else [sync_loop]
|
|
96
97
|
|
|
98
|
+
@property
|
|
99
|
+
def keep_version_file(self) -> bool:
|
|
100
|
+
if self.options.get("keep_version_file"):
|
|
101
|
+
return True
|
|
102
|
+
# If the version file is already there and the version is greater than the current version, keep it.
|
|
103
|
+
try:
|
|
104
|
+
serialized_version_file = self.read_file(self.exec_path(self.code_model.namespace) / "_version.py")
|
|
105
|
+
match = re.search(r'VERSION\s*=\s*"([^"]+)"', str(serialized_version_file))
|
|
106
|
+
serialized_version = match.group(1) if match else ""
|
|
107
|
+
except (FileNotFoundError, IndexError):
|
|
108
|
+
serialized_version = ""
|
|
109
|
+
return serialized_version > self.code_model.options["package_version"]
|
|
110
|
+
|
|
97
111
|
def serialize(self) -> None:
|
|
98
112
|
env = Environment(
|
|
99
113
|
loader=PackageLoader("pygen.codegen", "templates"),
|
|
@@ -193,6 +207,9 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
193
207
|
file = template_name.replace(".jinja2", "")
|
|
194
208
|
output_name = root_of_sdk / file
|
|
195
209
|
if not self.read_file(output_name) or file in _REGENERATE_FILES:
|
|
210
|
+
if self.keep_version_file and file == "setup.py":
|
|
211
|
+
# don't regenerate setup.py file if the version file is more up to date
|
|
212
|
+
continue
|
|
196
213
|
self.write_file(
|
|
197
214
|
output_name,
|
|
198
215
|
serializer.serialize_package_file(template_name, **params),
|
|
@@ -329,10 +346,9 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
329
346
|
_read_version_file(original_version_file_name),
|
|
330
347
|
)
|
|
331
348
|
|
|
332
|
-
keep_version_file
|
|
333
|
-
if keep_version_file and _read_version_file("_version.py"):
|
|
349
|
+
if self.keep_version_file and _read_version_file("_version.py"):
|
|
334
350
|
_write_version_file(original_version_file_name="_version.py")
|
|
335
|
-
elif keep_version_file and _read_version_file("version.py"):
|
|
351
|
+
elif self.keep_version_file and _read_version_file("version.py"):
|
|
336
352
|
_write_version_file(original_version_file_name="version.py")
|
|
337
353
|
elif self.code_model.options["package_version"]:
|
|
338
354
|
self.write_file(
|
|
Binary file
|
package/generator/pygen/black.py
CHANGED
|
@@ -60,7 +60,7 @@ class BlackScriptPlugin(Plugin):
|
|
|
60
60
|
except:
|
|
61
61
|
_LOGGER.error("Error: failed to format %s", file)
|
|
62
62
|
raise
|
|
63
|
-
if len(file_content.splitlines()) > 1000:
|
|
63
|
+
if len(file_content.splitlines()) > 1000 and "pylint: disable=too-many-lines" not in file_content:
|
|
64
64
|
file_content = "# pylint: disable=too-many-lines\n" + file_content
|
|
65
65
|
self.write_file(file, file_content)
|
|
66
66
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
7
|
from collections import namedtuple
|
|
8
|
+
import re
|
|
8
9
|
from typing import List, Any, Union
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from jinja2 import PackageLoader, Environment, FileSystemLoader, StrictUndefined
|
|
@@ -94,6 +95,19 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
94
95
|
async_loop = AsyncInfo(async_mode=True, async_path="aio/")
|
|
95
96
|
return [sync_loop, async_loop] if self.has_aio_folder else [sync_loop]
|
|
96
97
|
|
|
98
|
+
@property
|
|
99
|
+
def keep_version_file(self) -> bool:
|
|
100
|
+
if self.options.get("keep_version_file"):
|
|
101
|
+
return True
|
|
102
|
+
# If the version file is already there and the version is greater than the current version, keep it.
|
|
103
|
+
try:
|
|
104
|
+
serialized_version_file = self.read_file(self.exec_path(self.code_model.namespace) / "_version.py")
|
|
105
|
+
match = re.search(r'VERSION\s*=\s*"([^"]+)"', str(serialized_version_file))
|
|
106
|
+
serialized_version = match.group(1) if match else ""
|
|
107
|
+
except (FileNotFoundError, IndexError):
|
|
108
|
+
serialized_version = ""
|
|
109
|
+
return serialized_version > self.code_model.options["package_version"]
|
|
110
|
+
|
|
97
111
|
def serialize(self) -> None:
|
|
98
112
|
env = Environment(
|
|
99
113
|
loader=PackageLoader("pygen.codegen", "templates"),
|
|
@@ -193,6 +207,9 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
193
207
|
file = template_name.replace(".jinja2", "")
|
|
194
208
|
output_name = root_of_sdk / file
|
|
195
209
|
if not self.read_file(output_name) or file in _REGENERATE_FILES:
|
|
210
|
+
if self.keep_version_file and file == "setup.py":
|
|
211
|
+
# don't regenerate setup.py file if the version file is more up to date
|
|
212
|
+
continue
|
|
196
213
|
self.write_file(
|
|
197
214
|
output_name,
|
|
198
215
|
serializer.serialize_package_file(template_name, **params),
|
|
@@ -329,10 +346,9 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
329
346
|
_read_version_file(original_version_file_name),
|
|
330
347
|
)
|
|
331
348
|
|
|
332
|
-
keep_version_file
|
|
333
|
-
if keep_version_file and _read_version_file("_version.py"):
|
|
349
|
+
if self.keep_version_file and _read_version_file("_version.py"):
|
|
334
350
|
_write_version_file(original_version_file_name="_version.py")
|
|
335
|
-
elif keep_version_file and _read_version_file("version.py"):
|
|
351
|
+
elif self.keep_version_file and _read_version_file("version.py"):
|
|
336
352
|
_write_version_file(original_version_file_name="version.py")
|
|
337
353
|
elif self.code_model.options["package_version"]:
|
|
338
354
|
self.write_file(
|