ssc_codegen 0.24.0__tar.gz → 0.25.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.24.0 → ssc_codegen-0.25.0}/PKG-INFO +1 -1
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/pyproject.toml +1 -1
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/jsondef.py +1 -1
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/linting.py +21 -10
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/module_handler.py +2 -4
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/struct_parser.py +7 -1
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/.gitignore +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/LICENSE +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/README.md +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/__init__.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/_logging.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/__init__.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/array.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/base.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/cast.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/control.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/extract.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/helpers.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/module.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/predicate_containers.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/predicate_ops.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/regex.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/selectors.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/string.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/struct.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/transform.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/typedef.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/ast/types.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/helpers.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/js_pure.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_helpers.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_lxml.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_render.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/py_slax.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/converters/request_spec.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/__init__.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/adapter.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/contexts.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/expressions.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/format.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/predicates.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/reader.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/core/type_checking.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/document_utils.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/exceptions.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/health.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/kdl/__init__.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/kdl/dict_reader.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/kdl/parser.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/kdl/reader.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/main.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/parsers/__init__.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/parsers/curl.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/parsers/http.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/pseudo_selectors.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.0}/ssc_codegen/regex_utils.py +0 -0
- {ssc_codegen-0.24.0 → ssc_codegen-0.25.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.25.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
|
|
@@ -34,7 +34,7 @@ class JsonDefField(Node):
|
|
|
34
34
|
class JsonDef(Node):
|
|
35
35
|
"""
|
|
36
36
|
JSON mapping definition.
|
|
37
|
-
DSL: json Name { ... } / json Name
|
|
37
|
+
DSL: json Name { ... } / (array)json Name { ... } / json Name path="a.b" { ... }
|
|
38
38
|
body: list[JsonDefField]
|
|
39
39
|
"""
|
|
40
40
|
|
|
@@ -952,15 +952,6 @@ def lint_json_node(node: KdlNode, lint: LintContext, ctx: ParseContext) -> None:
|
|
|
952
952
|
hint=f"rename or remove one of the 'json {name}' definitions",
|
|
953
953
|
)
|
|
954
954
|
|
|
955
|
-
array_prop = node.properties.get("array")
|
|
956
|
-
if array_prop is not None and not isinstance(array_prop.value, bool):
|
|
957
|
-
lint.error(
|
|
958
|
-
node,
|
|
959
|
-
message=f"'array' property must be boolean (#true/#false), got {array_prop.value!r}",
|
|
960
|
-
code="E002",
|
|
961
|
-
hint="example: json MySchema array=#true { ... }",
|
|
962
|
-
)
|
|
963
|
-
|
|
964
955
|
path_prop = node.properties.get("path")
|
|
965
956
|
if path_prop is not None:
|
|
966
957
|
path_val = str(path_prop.value)
|
|
@@ -975,9 +966,29 @@ def lint_json_node(node: KdlNode, lint: LintContext, ctx: ParseContext) -> None:
|
|
|
975
966
|
# ── field-level checks ───────────────────────────────────────────────────
|
|
976
967
|
|
|
977
968
|
seen_fields: set[str] = set()
|
|
978
|
-
|
|
969
|
+
_lint_json_children(lint.get_children_nodes(node), lint, ctx, seen_fields)
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
def _lint_json_children(
|
|
973
|
+
children: list[KdlNode],
|
|
974
|
+
lint: LintContext,
|
|
975
|
+
ctx: ParseContext,
|
|
976
|
+
seen_fields: set[str],
|
|
977
|
+
) -> None:
|
|
978
|
+
"""Lint json field children, expanding block define references."""
|
|
979
|
+
for field_node in children:
|
|
979
980
|
field_name = lint.node_name(field_node)
|
|
980
981
|
args = lint.get_args(field_node)
|
|
982
|
+
|
|
983
|
+
# Block define expansion
|
|
984
|
+
if not args and field_name in ctx.children_defines:
|
|
985
|
+
lint.push(field_name)
|
|
986
|
+
_lint_json_children(
|
|
987
|
+
ctx.children_defines[field_name], lint, ctx, seen_fields
|
|
988
|
+
)
|
|
989
|
+
lint.pop()
|
|
990
|
+
continue
|
|
991
|
+
|
|
981
992
|
has_type = False
|
|
982
993
|
has_skip = False
|
|
983
994
|
for arg in args:
|
|
@@ -83,9 +83,7 @@ def handle_json(
|
|
|
83
83
|
node: KdlNode, module: Module, ctx: ParseContext, lint: LintContext
|
|
84
84
|
) -> JsonDef:
|
|
85
85
|
name = str(node.args[0].value) if node.args else ""
|
|
86
|
-
is_array = node.
|
|
87
|
-
"array", KdlArg(value=False, span=node.span, is_identifier=False)
|
|
88
|
-
).value
|
|
86
|
+
is_array = node.type_annotation == "(array)"
|
|
89
87
|
path = str(
|
|
90
88
|
node.properties.get(
|
|
91
89
|
"path", KdlArg(value="", span=node.span, is_identifier=False)
|
|
@@ -93,7 +91,7 @@ def handle_json(
|
|
|
93
91
|
)
|
|
94
92
|
json_def = JsonDef(parent=module, name=name, is_array=is_array, path=path)
|
|
95
93
|
lint_json_node(node, lint, ctx)
|
|
96
|
-
parse_json_fields(node.children, json_def)
|
|
94
|
+
parse_json_fields(node.children, json_def, ctx)
|
|
97
95
|
ctx.json_defs[json_def.name] = json_def
|
|
98
96
|
if name:
|
|
99
97
|
lint.json_kdl_nodes[name] = node
|
|
@@ -184,8 +184,14 @@ def parse_struct(
|
|
|
184
184
|
lint.walk_context = prev_ctx
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def parse_json_fields(
|
|
187
|
+
def parse_json_fields(
|
|
188
|
+
nodes: Sequence[KdlNode], parent: JsonDef, ctx: ParseContext
|
|
189
|
+
) -> None:
|
|
188
190
|
for node in nodes:
|
|
191
|
+
# Block define expansion in json context
|
|
192
|
+
if not node.args and node.name in ctx.children_defines:
|
|
193
|
+
parse_json_fields(ctx.children_defines[node.name], parent, ctx)
|
|
194
|
+
continue
|
|
189
195
|
name = node.name
|
|
190
196
|
modifiers: list[str] = []
|
|
191
197
|
type_ = ""
|
|
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
|