ssc_codegen 0.7.5__tar.gz → 0.7.7__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.7.5 → ssc_codegen-0.7.7}/PKG-INFO +1 -1
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/pyproject.toml +1 -1
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/__init__.py +1 -1
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/ast_build_utils.py +26 -3
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/ast_builder.py +10 -8
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/ast_ssc.py +1 -6
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/tokens.py +4 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/.gitignore +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/LICENSE +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/README.md +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/_compat.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/__init__.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/cli_callbacks.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/cli_utils.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/code_callbacks.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/consts.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/main.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/cli/runtime_parse_runners.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/compiler.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/consts.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/__init__.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/ast_utils.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/dart_universal_html.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/go_goquery.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/js_pure.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/json_to_schema.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/py_base.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/py_scrapy.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/py_selectolax.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/dart.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/go.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/js.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/py.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/template_bindings.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/document.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/document_utlis.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/json_struct.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/schema.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/selector_utils.py +0 -0
- {ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/str_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.7
|
|
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
|
|
@@ -126,6 +126,10 @@ def extract_json_structs_from_module(module: ModuleType) -> list[Type[Json]]:
|
|
|
126
126
|
def assert_ret_type_not_document(
|
|
127
127
|
field: "BaseDocument", name: str, schema: Type[BaseSchema]
|
|
128
128
|
) -> None:
|
|
129
|
+
# always ret nil, skip
|
|
130
|
+
if name == "__PRE_VALIDATE__":
|
|
131
|
+
return
|
|
132
|
+
|
|
129
133
|
if field.stack_last_ret == VariableType.DOCUMENT:
|
|
130
134
|
msg = f"{schema.__name__}.{name} cannot return type {VariableType.DOCUMENT.name}"
|
|
131
135
|
raise TypeError(msg)
|
|
@@ -212,16 +216,29 @@ def cast_ret_type_to_optional(ret_type: VariableType) -> VariableType:
|
|
|
212
216
|
return ret_type
|
|
213
217
|
|
|
214
218
|
|
|
215
|
-
def
|
|
219
|
+
def scan_field_stack_expr(field: BaseDocument) -> None:
|
|
216
220
|
"""validate correct type expressions pass.
|
|
217
221
|
|
|
218
|
-
raise TypeError if not passed
|
|
222
|
+
raise TypeError if not scan passed
|
|
219
223
|
"""
|
|
220
224
|
var_cursor = VariableType.DOCUMENT
|
|
221
225
|
for expr in field.stack:
|
|
222
226
|
if var_cursor == expr.accept_type:
|
|
223
227
|
var_cursor = expr.ret_type
|
|
224
228
|
continue
|
|
229
|
+
# currently used in to_len() operation
|
|
230
|
+
elif expr.accept_type == VariableType.LIST_ANY:
|
|
231
|
+
if var_cursor in (
|
|
232
|
+
VariableType.LIST_STRING,
|
|
233
|
+
VariableType.LIST_DOCUMENT,
|
|
234
|
+
VariableType.LIST_FLOAT,
|
|
235
|
+
VariableType.LIST_INT,
|
|
236
|
+
):
|
|
237
|
+
var_cursor = expr.ret_type
|
|
238
|
+
continue
|
|
239
|
+
msg = f".to_len() expected LIST_ANY type, got '{var_cursor.name}'"
|
|
240
|
+
raise TypeError(msg)
|
|
241
|
+
|
|
225
242
|
# this type always first (naive, used in DEFAULT and RETURN expr)
|
|
226
243
|
elif expr.accept_type == VariableType.ANY:
|
|
227
244
|
var_cursor = VariableType.DOCUMENT
|
|
@@ -229,8 +246,14 @@ def assert_field_document_variable_types(field: BaseDocument) -> None:
|
|
|
229
246
|
# end token operation, ignore
|
|
230
247
|
elif expr.kind == TokenType.EXPR_DEFAULT_END:
|
|
231
248
|
continue
|
|
249
|
+
# end operations
|
|
232
250
|
elif var_cursor == VariableType.NESTED:
|
|
233
|
-
raise TypeError("sub_parser not allowed next instructions")
|
|
251
|
+
raise TypeError(".sub_parser() not allowed next instructions")
|
|
252
|
+
elif var_cursor == VariableType.JSON:
|
|
253
|
+
raise TypeError(".jsonify() not allowed next instructions")
|
|
254
|
+
elif var_cursor == VariableType.OPTIONAL_JSON:
|
|
255
|
+
raise TypeError(".jsonify() not allowed next instructions")
|
|
234
256
|
|
|
257
|
+
# not covered cases
|
|
235
258
|
msg = f"'{expr.kind.name}' expected type '{expr.accept_type.name}', got '{var_cursor.name}'"
|
|
236
259
|
raise TypeError(msg)
|
|
@@ -14,7 +14,7 @@ from .ast_build_utils import (
|
|
|
14
14
|
unwrap_default_expr,
|
|
15
15
|
assert_split_doc_ret_type_is_list_document,
|
|
16
16
|
cast_ret_type_to_optional,
|
|
17
|
-
|
|
17
|
+
scan_field_stack_expr,
|
|
18
18
|
extract_json_structs_from_module,
|
|
19
19
|
)
|
|
20
20
|
from .ast_ssc import (
|
|
@@ -60,15 +60,17 @@ def fill_variables_stack_expr(
|
|
|
60
60
|
# set DefaultEnd ret_type as DefaultStartToken
|
|
61
61
|
tmp_stack[-1].ret_type = ret_type
|
|
62
62
|
elif isinstance(first_expr.value, str): # type: ignore[attr-defined]
|
|
63
|
-
tmp_stack[-1].ret_type = VariableType.STRING
|
|
64
|
-
if ret_type != VariableType.STRING:
|
|
65
|
-
msg = f"wrong default type passed (should be a STRING or NULL, got {ret_type.name})"
|
|
66
|
-
raise TypeError(msg)
|
|
67
|
-
elif isinstance(first_expr.value, float): # type: ignore[attr-defined]
|
|
68
63
|
tmp_stack[-1].ret_type = VariableType.FLOAT
|
|
69
64
|
if ret_type != VariableType.FLOAT:
|
|
70
65
|
msg = f"wrong default type passed (should be a FLOAT or NULL, got {ret_type.name})"
|
|
71
66
|
raise TypeError(msg)
|
|
67
|
+
|
|
68
|
+
elif isinstance(first_expr.value, bool): # type: ignore[attr-defined]
|
|
69
|
+
tmp_stack[-1].ret_type = VariableType.BOOL
|
|
70
|
+
if ret_type != VariableType.BOOL:
|
|
71
|
+
msg = f"wrong default type passed (should be a BOOL or NULL, got {ret_type.name})"
|
|
72
|
+
raise TypeError(msg)
|
|
73
|
+
|
|
72
74
|
elif isinstance(first_expr.value, int): # type: ignore[attr-defined]
|
|
73
75
|
tmp_stack[-1].ret_type = VariableType.INT
|
|
74
76
|
if ret_type != VariableType.INT:
|
|
@@ -152,11 +154,11 @@ def build_ast_struct(
|
|
|
152
154
|
start_parse_body: list[CallStructFunctionExpression] = []
|
|
153
155
|
struct_parse_functions: list[BaseAstNode] = []
|
|
154
156
|
for name, field in fields.items():
|
|
155
|
-
|
|
157
|
+
scan_field_stack_expr(field)
|
|
156
158
|
|
|
157
159
|
# not allowed empty stack exprs
|
|
158
160
|
if len(field.stack) == 0:
|
|
159
|
-
msg = f"{schema.__name__}.{name} has
|
|
161
|
+
msg = f"{schema.__name__}.{name} has empty expressions"
|
|
160
162
|
raise SyntaxError(msg)
|
|
161
163
|
|
|
162
164
|
if css_to_xpath:
|
|
@@ -427,12 +427,7 @@ class JoinExpression(BaseExpression):
|
|
|
427
427
|
@dataclass(kw_only=True)
|
|
428
428
|
class ArrayLengthExpression(BaseExpression):
|
|
429
429
|
kind: ClassVar[TokenType] = TokenType.EXPR_LIST_LEN
|
|
430
|
-
accept_type: VariableType =
|
|
431
|
-
VariableType.LIST_STRING
|
|
432
|
-
| VariableType.LIST_DOCUMENT
|
|
433
|
-
| VariableType.LIST_INT
|
|
434
|
-
| VariableType.LIST_FLOAT
|
|
435
|
-
)
|
|
430
|
+
accept_type: VariableType = VariableType.LIST_ANY
|
|
436
431
|
ret_type: VariableType = VariableType.INT
|
|
437
432
|
|
|
438
433
|
|
|
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
|
{ssc_codegen-0.7.5 → ssc_codegen-0.7.7}/ssc_codegen/converters/templates/template_bindings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|