ssc_codegen 0.8.15__tar.gz → 0.8.16__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.15 → ssc_codegen-0.8.16}/PKG-INFO +1 -1
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/pyproject.toml +1 -1
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/__init__.py +1 -1
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/js_pure.py +18 -16
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/.gitignore +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/LICENSE +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/README.md +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/_compat.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/base.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_array.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_cast.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_core.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_selectors.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_string.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_/nodes_validate.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_build/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_build/main.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/ast_build/utils.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/cli_callbacks.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/cli_utils.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/code_callbacks.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/consts.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/main.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/cli/runtime_parse_runners.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/compiler.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/consts.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/go_goquery.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/helpers.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/py_base.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/py_selectolax.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/templates/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/templates/go_goquery.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/converters/templates/js_pure.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/document.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/document_utlis.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/json_struct.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/json_to_scc.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/logs.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/pseudo_selectors.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/schema.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/selector_utils.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/static_checker/__init__.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/static_checker/base.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/static_checker/callbacks.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/ssc_codegen/str_utils.py +0 -0
- {ssc_codegen-0.8.15 → ssc_codegen-0.8.16}/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.16
|
|
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
|
|
@@ -129,6 +129,17 @@ DOCSTR_SEP = "* "
|
|
|
129
129
|
CONVERTER = BaseCodeConverter(debug_comment_prefix="// ")
|
|
130
130
|
|
|
131
131
|
|
|
132
|
+
# TODO: move to string_utils
|
|
133
|
+
def to_js_regexp(pattern: str, ignore_case: bool = False) -> str:
|
|
134
|
+
"""helper function for convert string pattern to js"""
|
|
135
|
+
pattern = pattern.replace("<\\/", "</")
|
|
136
|
+
pattern = pattern.replace("/", "\\/")
|
|
137
|
+
pattern = f"/{pattern}/g"
|
|
138
|
+
if ignore_case:
|
|
139
|
+
pattern += "i"
|
|
140
|
+
return pattern
|
|
141
|
+
|
|
142
|
+
|
|
132
143
|
def make_js_docstring(value: str) -> str:
|
|
133
144
|
if not value:
|
|
134
145
|
return ""
|
|
@@ -357,10 +368,7 @@ def pre_list_str_replace(node: ExprListStringReplace) -> str:
|
|
|
357
368
|
def pre_str_regex(node: ExprStringRegex) -> str:
|
|
358
369
|
prv, nxt = prev_next_var(node)
|
|
359
370
|
pattern, group, ignore_case = node.unpack_args()
|
|
360
|
-
pattern = pattern
|
|
361
|
-
pattern = f"/{pattern}/g"
|
|
362
|
-
if ignore_case:
|
|
363
|
-
pattern += "i"
|
|
371
|
+
pattern = to_js_regexp(pattern, ignore_case)
|
|
364
372
|
return f"let {nxt} = (new RegExp({pattern})).exec({prv})[{group}];"
|
|
365
373
|
|
|
366
374
|
|
|
@@ -368,10 +376,8 @@ def pre_str_regex(node: ExprStringRegex) -> str:
|
|
|
368
376
|
def pre_str_regex_all(node: ExprStringRegexAll) -> str:
|
|
369
377
|
prv, nxt = prev_next_var(node)
|
|
370
378
|
pattern, ignore_case = node.unpack_args()
|
|
371
|
-
pattern = pattern
|
|
372
|
-
|
|
373
|
-
if ignore_case:
|
|
374
|
-
pattern += "i"
|
|
379
|
+
pattern = to_js_regexp(pattern, ignore_case)
|
|
380
|
+
|
|
375
381
|
return f"let {nxt} = (new RegExp({pattern})).exec({prv});"
|
|
376
382
|
|
|
377
383
|
|
|
@@ -379,8 +385,7 @@ def pre_str_regex_all(node: ExprStringRegexAll) -> str:
|
|
|
379
385
|
def pre_str_regex_sub(node: ExprStringRegexSub) -> str:
|
|
380
386
|
prv, nxt = prev_next_var(node)
|
|
381
387
|
pattern, repl = node.unpack_args()
|
|
382
|
-
pattern = pattern
|
|
383
|
-
pattern = f"/{pattern}/g"
|
|
388
|
+
pattern = to_js_regexp(pattern)
|
|
384
389
|
|
|
385
390
|
return f"let {nxt} = {prv}.replace({pattern}, {repl!r});"
|
|
386
391
|
|
|
@@ -389,8 +394,8 @@ def pre_str_regex_sub(node: ExprStringRegexSub) -> str:
|
|
|
389
394
|
def pre_list_str_regex_sub(node: ExprListStringRegexSub) -> str:
|
|
390
395
|
prv, nxt = prev_next_var(node)
|
|
391
396
|
pattern, repl = node.unpack_args()
|
|
392
|
-
pattern = pattern
|
|
393
|
-
|
|
397
|
+
pattern = to_js_regexp(pattern)
|
|
398
|
+
|
|
394
399
|
return f"let {nxt} = {prv}.map(e => e.replace({pattern}, {repl!r}));"
|
|
395
400
|
|
|
396
401
|
|
|
@@ -456,10 +461,7 @@ def pre_is_contains(node: ExprIsContains) -> str:
|
|
|
456
461
|
def pre_is_regex(node: ExprStringIsRegex) -> str:
|
|
457
462
|
prv, nxt = prev_next_var(node)
|
|
458
463
|
pattern, ignore_case, msg = node.unpack_args()
|
|
459
|
-
pattern = pattern
|
|
460
|
-
pattern = f"/{pattern}/g"
|
|
461
|
-
if ignore_case:
|
|
462
|
-
pattern += "i"
|
|
464
|
+
pattern = to_js_regexp(pattern, ignore_case)
|
|
463
465
|
|
|
464
466
|
expr = f"if ({prv}.match({pattern}) === null) throw new Error({msg!r});"
|
|
465
467
|
if is_last_var_no_ret(node):
|
|
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
|