ssc_codegen 0.8.13__tar.gz → 0.8.14__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.
Potentially problematic release.
This version of ssc_codegen might be problematic. Click here for more details.
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/PKG-INFO +1 -1
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/pyproject.toml +1 -1
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/__init__.py +1 -1
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_build/main.py +28 -13
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/document_utlis.py +8 -2
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/.gitignore +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/LICENSE +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/README.md +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/_compat.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/base.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_array.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_cast.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_core.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_selectors.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_string.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_/nodes_validate.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_build/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/ast_build/utils.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/cli_callbacks.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/cli_utils.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/code_callbacks.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/consts.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/main.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/cli/runtime_parse_runners.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/compiler.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/consts.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/go_goquery.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/helpers.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/js_pure.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/py_base.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/py_selectolax.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/templates/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/templates/go_goquery.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/converters/templates/js_pure.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/document.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/json_struct.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/json_to_scc.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/logs.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/pseudo_selectors.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/schema.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/selector_utils.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/static_checker/__init__.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/static_checker/base.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/static_checker/callbacks.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/str_utils.py +0 -0
- {ssc_codegen-0.8.13 → ssc_codegen-0.8.14}/ssc_codegen/tokens.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.14
|
|
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
|
|
@@ -77,15 +77,32 @@ def build_ast_module_parser(
|
|
|
77
77
|
json_structs = extract_json_structs_from_module(py_module)
|
|
78
78
|
# TODO: API for build single json
|
|
79
79
|
ast_jsons = build_ast_json(ast_module, *json_structs)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
# TODO: implement analyze-only AST function
|
|
81
|
+
try:
|
|
82
|
+
ast_schemas = [
|
|
83
|
+
build_ast_struct_parser(
|
|
84
|
+
sc,
|
|
85
|
+
ast_module,
|
|
86
|
+
css_to_xpath=css_to_xpath,
|
|
87
|
+
xpath_to_css=xpath_to_css,
|
|
88
|
+
)
|
|
89
|
+
for sc in schemas
|
|
90
|
+
]
|
|
91
|
+
except SyntaxError:
|
|
92
|
+
# get all schemas exceptions and throw to logs:
|
|
93
|
+
errors = []
|
|
94
|
+
for sc in schemas:
|
|
95
|
+
try:
|
|
96
|
+
build_ast_struct_parser(
|
|
97
|
+
sc,
|
|
98
|
+
ast_module,
|
|
99
|
+
css_to_xpath=css_to_xpath,
|
|
100
|
+
xpath_to_css=xpath_to_css,
|
|
101
|
+
)
|
|
102
|
+
except SyntaxError as e:
|
|
103
|
+
errors.append(e)
|
|
104
|
+
raise SyntaxError(f"{path}: Founded errors: {len(errors)}")
|
|
105
|
+
|
|
89
106
|
# TODO: API for build single typedef
|
|
90
107
|
ast_typedefs = build_ast_typedef(ast_module, *ast_schemas)
|
|
91
108
|
module_body.extend(ast_jsons)
|
|
@@ -173,7 +190,6 @@ def build_ast_struct_parser(
|
|
|
173
190
|
) -> StructParser:
|
|
174
191
|
errors_count = run_analyze_schema(schema)
|
|
175
192
|
if errors_count > 0:
|
|
176
|
-
# todo: exc
|
|
177
193
|
msg = f"{schema.__name__} founded errors: {errors_count}"
|
|
178
194
|
raise SyntaxError(msg)
|
|
179
195
|
docstring = (
|
|
@@ -237,8 +253,7 @@ def _fetch_field_nodes(
|
|
|
237
253
|
)
|
|
238
254
|
# TODO: add ast tests
|
|
239
255
|
# in inheritance schemas, child classes use same fields are used as in the parent class
|
|
240
|
-
# avoid duplicate ExprReturn node
|
|
241
|
-
# second case used in ExprDefaultValueWrapper cases
|
|
256
|
+
# avoid duplicate ExprReturn or ExprDefaultValueWrapper node
|
|
242
257
|
if (
|
|
243
258
|
document.stack[-1].kind != ExprReturn.kind
|
|
244
259
|
and document.stack[-1].kind != TokenType.EXPR_DEFAULT_END
|
|
@@ -335,7 +350,7 @@ def _try_fetch_split_doc_node(
|
|
|
335
350
|
method = StructPartDocMethod(parent=st_ref)
|
|
336
351
|
|
|
337
352
|
# in inheritance schemas, child classes use same fields are used as in the parent class
|
|
338
|
-
#
|
|
353
|
+
# avoid duplicate ExprReturn or ExprDefaultValueWrapper node
|
|
339
354
|
if (
|
|
340
355
|
split_doc.stack[-1].kind != ExprReturn.kind
|
|
341
356
|
and split_doc.stack[-1].kind != TokenType.EXPR_DEFAULT_END
|
|
@@ -31,6 +31,8 @@ CM1_RX = r"(?m)(?<!\\)((\\{2})*)#.*$"
|
|
|
31
31
|
CM2_RX = r"(\\)?((\\{2})*)(#)"
|
|
32
32
|
WS_RX = r"(\\)?((\\{2})*)(\s)\s*"
|
|
33
33
|
|
|
34
|
+
RE_CAPTURED_GROUPS = re.compile(r"(?<!\()\((?!\?:)[^)]+\)")
|
|
35
|
+
|
|
34
36
|
|
|
35
37
|
def is_ignore_case_regex(pattern: str | Pattern) -> bool:
|
|
36
38
|
if isinstance(pattern, str):
|
|
@@ -76,10 +78,14 @@ def analyze_re_expression(
|
|
|
76
78
|
try:
|
|
77
79
|
re_pattern = re.compile(pattern)
|
|
78
80
|
if not allow_empty_groups and re_pattern.groups == 0:
|
|
79
|
-
msg = f"`{re_pattern.pattern}` pattern groups is empty"
|
|
81
|
+
msg = f"`{re_pattern.pattern}` pattern groups is empty."
|
|
82
|
+
msg += "\nTIP: maybe you remember wrap pattern to brackets `()`?"
|
|
80
83
|
return AnalyzeResult.error(msg)
|
|
81
84
|
elif max_groups != -1 and re_pattern.groups > max_groups:
|
|
82
|
-
|
|
85
|
+
captured_groups = RE_CAPTURED_GROUPS.findall(re_pattern.pattern)
|
|
86
|
+
msg = f"`{re_pattern.pattern}` too many groups in pattern, expected groups count: {max_groups}."
|
|
87
|
+
msg += f"\nTIP: fix regular expression for extract {max_groups}:"
|
|
88
|
+
msg += f"\nGroups founded: {captured_groups}"
|
|
83
89
|
return AnalyzeResult.error(msg)
|
|
84
90
|
except re.error as e:
|
|
85
91
|
msg = f"`{pattern}` wrong regex pattern syntax: {e!r}"
|
|
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
|