ssc_codegen 0.27.0__tar.gz → 0.28.0__tar.gz
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.
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/PKG-INFO +1 -1
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/pyproject.toml +1 -1
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/js_pure.py +7 -7
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/py_bs4.py +6 -6
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/.gitignore +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/LICENSE +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/README.md +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/__init__.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/_logging.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/__init__.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/array.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/base.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/cast.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/control.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/extract.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/helpers.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/jsondef.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/module.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/predicate_containers.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/predicate_ops.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/regex.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/selectors.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/string.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/struct.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/transform.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/typedef.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/ast/types.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/helpers.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/py_lxml.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/py_render.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/py_slax.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/converters/request_spec.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/__init__.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/adapter.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/contexts.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/expressions.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/format.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/linting.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/module_handler.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/predicates.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/reader.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/struct_parser.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/core/type_checking.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/document_utils.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/exceptions.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/health.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/kdl/__init__.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/kdl/dict_reader.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/kdl/parser.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/kdl/reader.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/main.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/parsers/__init__.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/parsers/curl.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/parsers/http.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/pseudo_selectors.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/regex_utils.py +0 -0
- {ssc_codegen-0.27.0 → ssc_codegen-0.28.0}/ssc_codegen/selector_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0
|
|
4
4
|
Summary: Python-dsl code converter to html parser for web scraping
|
|
5
5
|
Project-URL: Documentation, https://github.com/vypivshiy/selector_schema_codegen#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/vypivshiy/selector_schema_codegen/issues
|
|
@@ -259,7 +259,7 @@ def pre_utilities(node: a.Utilities, _: ConverterContext):
|
|
|
259
259
|
" * @property {string} cause",
|
|
260
260
|
" */",
|
|
261
261
|
"",
|
|
262
|
-
"async function
|
|
262
|
+
"async function sscParseResponse(_resp) {",
|
|
263
263
|
" const _status = _resp.status;",
|
|
264
264
|
" const _headers = Object.fromEntries"
|
|
265
265
|
"([..._resp.headers.entries()]);",
|
|
@@ -268,7 +268,7 @@ def pre_utilities(node: a.Utilities, _: ConverterContext):
|
|
|
268
268
|
" return [_status, _headers, _body];",
|
|
269
269
|
"}",
|
|
270
270
|
"",
|
|
271
|
-
"function
|
|
271
|
+
"function sscParseResponseAxios(_resp) {",
|
|
272
272
|
" const _status = _resp.status;",
|
|
273
273
|
" const _headers = {};",
|
|
274
274
|
" for (const [k, v] of Object.entries(_resp.headers || {})) "
|
|
@@ -464,7 +464,7 @@ def pre_struct_rest(node: a.StructRest, ctx: ConverterContext):
|
|
|
464
464
|
)
|
|
465
465
|
lines.extend(doc_lines)
|
|
466
466
|
lines.append(f"class {name} " + "{")
|
|
467
|
-
#
|
|
467
|
+
# sscDispatchErr static method (first member of class body)
|
|
468
468
|
lines.extend(_emit_dispatch_err_js(node, ctx.deeper()))
|
|
469
469
|
return lines
|
|
470
470
|
|
|
@@ -475,7 +475,7 @@ def pre_struct_docstring(node: a.StructDocstring, ctx: ConverterContext):
|
|
|
475
475
|
|
|
476
476
|
|
|
477
477
|
def _emit_dispatch_err_js(node: a.Struct, ctx: ConverterContext) -> list[str]:
|
|
478
|
-
"""Emit `
|
|
478
|
+
"""Emit `sscDispatchErr` static method inside a REST class body."""
|
|
479
479
|
i1 = ctx.indent # class-body level
|
|
480
480
|
i2 = i1 + ctx.indent_char # method body
|
|
481
481
|
i3 = i2 + ctx.indent_char # nested (if ...)
|
|
@@ -487,7 +487,7 @@ def _emit_dispatch_err_js(node: a.Struct, ctx: ConverterContext) -> list[str]:
|
|
|
487
487
|
field_errors = [e for e in errors if e.conditions or e.required_keys]
|
|
488
488
|
|
|
489
489
|
lines: list[str] = [
|
|
490
|
-
f"{i1}static
|
|
490
|
+
f"{i1}static sscDispatchErr(_status, _headers, _body) {{",
|
|
491
491
|
f"{i2}if (_status >= 200 && _status < 300) {{",
|
|
492
492
|
]
|
|
493
493
|
for err in field_errors:
|
|
@@ -1964,7 +1964,7 @@ def _js_rest_method(node: a.RequestConfig, ctx: ConverterContext) -> list[str]:
|
|
|
1964
1964
|
|
|
1965
1965
|
# Shared response extraction + dispatch
|
|
1966
1966
|
parser_fn = (
|
|
1967
|
-
"
|
|
1967
|
+
"sscParseResponseAxios" if http_client == "axios" else "sscParseResponse"
|
|
1968
1968
|
)
|
|
1969
1969
|
parse_prefix = "" if http_client == "axios" else "await "
|
|
1970
1970
|
lines.append(
|
|
@@ -1973,7 +1973,7 @@ def _js_rest_method(node: a.RequestConfig, ctx: ConverterContext) -> list[str]:
|
|
|
1973
1973
|
)
|
|
1974
1974
|
struct_pascal = to_pascal_case(struct_name) if struct_name else ""
|
|
1975
1975
|
lines.append(
|
|
1976
|
-
f"{i2}const _err = {struct_pascal}.
|
|
1976
|
+
f"{i2}const _err = {struct_pascal}.sscDispatchErr(_status, _headers, _body);"
|
|
1977
1977
|
)
|
|
1978
1978
|
lines.append(f"{i2}if (_err !== null) return _err;")
|
|
1979
1979
|
lines.append(
|
|
@@ -98,7 +98,7 @@ def runtime_export_names(node: a.Node) -> list[str]:
|
|
|
98
98
|
names = list(_BASE_EXPORT_NAMES)
|
|
99
99
|
if _module_has_rest(node):
|
|
100
100
|
names.extend(
|
|
101
|
-
["Ok", "Err", "UnknownErr", "TransportErr", "
|
|
101
|
+
["Ok", "Err", "UnknownErr", "TransportErr", "ssc_parse_response"]
|
|
102
102
|
)
|
|
103
103
|
return names
|
|
104
104
|
|
|
@@ -199,7 +199,7 @@ def rest_utilities(node: a.Node) -> list[str]:
|
|
|
199
199
|
" value: None = None",
|
|
200
200
|
" headers: Mapping[str, str] = field(default_factory=dict)",
|
|
201
201
|
"\n\n",
|
|
202
|
-
"def
|
|
202
|
+
"def ssc_parse_response(_resp):",
|
|
203
203
|
" _status = _resp.status_code",
|
|
204
204
|
" _headers = {k.lower(): v for k, v in _resp.headers.items()}",
|
|
205
205
|
" try:",
|
|
@@ -459,7 +459,7 @@ def _emit_dispatch_err(node: a.StructBase, ctx: ConverterContext) -> list[str]:
|
|
|
459
459
|
|
|
460
460
|
lines: list[str] = [
|
|
461
461
|
f"{i1}@staticmethod",
|
|
462
|
-
f"{i1}def
|
|
462
|
+
f"{i1}def ssc_dispatch_err("
|
|
463
463
|
f"_status: int, _headers: Mapping[str, str], _body: Any"
|
|
464
464
|
f") -> {union_type}:",
|
|
465
465
|
f"{i2}if 200 <= _status < 300:",
|
|
@@ -597,7 +597,7 @@ def pre_struct_rest(node: a.StructRest, ctx: ConverterContext):
|
|
|
597
597
|
lines.append("")
|
|
598
598
|
# Class header
|
|
599
599
|
lines.append(f"class {name}:")
|
|
600
|
-
#
|
|
600
|
+
# ssc_dispatch_err staticmethod (first member of class body, needs class-level indent)
|
|
601
601
|
lines.extend(_emit_dispatch_err(node, ctx.deeper()))
|
|
602
602
|
return lines
|
|
603
603
|
|
|
@@ -1824,8 +1824,8 @@ def _emit_rest_methods(
|
|
|
1824
1824
|
lines.append(f"{i3})")
|
|
1825
1825
|
lines.append(f"{i2}except httpx.HTTPError as _exc:")
|
|
1826
1826
|
lines.append(f"{i3}return TransportErr(cause=repr(_exc))")
|
|
1827
|
-
lines.append(f"{i2}_status, _headers, _body =
|
|
1828
|
-
lines.append(f"{i2}_err = cls.
|
|
1827
|
+
lines.append(f"{i2}_status, _headers, _body = ssc_parse_response(_resp)")
|
|
1828
|
+
lines.append(f"{i2}_err = cls.ssc_dispatch_err(_status, _headers, _body)")
|
|
1829
1829
|
lines.append(f"{i2}if _err is not None:")
|
|
1830
1830
|
lines.append(f"{i3}return _err")
|
|
1831
1831
|
lines.append(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|