ssc_codegen 0.9.8__tar.gz → 0.9.9__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.9.8 → ssc_codegen-0.9.9}/PKG-INFO +1 -1
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/pyproject.toml +1 -1
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/__init__.py +1 -1
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_build/utils.py +46 -7
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/js_pure.py +0 -1
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/.gitignore +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/LICENSE +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/README.md +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/_compat.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/base.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_array.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_cast.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_core.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_filter.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_selectors.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_string.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_/nodes_validate.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_build/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_build/main.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_grep_rules/js_rules.yml +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/ast_grep_rules/py_rules.yml +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/ast_grep.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/cli_callbacks.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/cli_utils.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/code_callbacks.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/consts.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/main.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/cli/runtime_parse_runners.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/compiler.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/consts.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/base.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/go_goquery.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/helpers.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/py_base.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/py_selectolax.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/templates/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/templates/go_goquery.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/converters/templates/js_pure.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/document.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/document_utlis.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/json_struct.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/json_to_scc.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/logs.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/pseudo_selectors.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/schema.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/selector_utils.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/static_checker/__init__.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/static_checker/base.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/static_checker/callbacks.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/str_utils.py +0 -0
- {ssc_codegen-0.9.8 → ssc_codegen-0.9.9}/ssc_codegen/tokens.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.9
|
|
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
|
|
@@ -90,20 +90,59 @@ def extract_json_structs_from_module(module: ModuleType) -> list[Type[Json]]:
|
|
|
90
90
|
]
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
def _add_sys_path(abs_path: Path) -> None:
|
|
94
|
+
# required for correct imports (eg: constants)
|
|
95
|
+
# TODO: calculate configs dirs depth
|
|
96
|
+
pathes = str(abs_path.parent), str(abs_path.parent.parent)
|
|
97
|
+
for p in pathes:
|
|
98
|
+
if p not in sys.path:
|
|
99
|
+
sys.path.append(p)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _is_not_dunder_obj(name: str) -> bool:
|
|
103
|
+
return not name.startswith("__") and not name.endswith("___")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _is_ssc_cls(name: str, cls: type) -> bool:
|
|
107
|
+
return (
|
|
108
|
+
_is_not_dunder_obj(name)
|
|
109
|
+
and hasattr(cls, "__mro__")
|
|
110
|
+
and BaseSchema in cls.__mro__
|
|
111
|
+
and not is_template_schema_cls(cls)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
93
115
|
def exec_module_code(path: str | Path, add_sys_path: bool = True) -> ModuleType:
|
|
94
116
|
# apologize, input - real python file
|
|
95
117
|
if isinstance(path, str):
|
|
96
118
|
path = Path(path)
|
|
97
|
-
module = ModuleType("_")
|
|
98
119
|
abs_path = path.resolve()
|
|
99
|
-
|
|
100
|
-
# TODO: calculate configs dirs depth
|
|
101
|
-
if add_sys_path and str(abs_path.parent) not in sys.path:
|
|
102
|
-
sys.path.append(str(abs_path.parent))
|
|
120
|
+
module = ModuleType("_")
|
|
103
121
|
|
|
104
|
-
if add_sys_path
|
|
105
|
-
|
|
122
|
+
if add_sys_path:
|
|
123
|
+
_add_sys_path(abs_path)
|
|
106
124
|
|
|
107
125
|
code = Path(abs_path).read_text()
|
|
108
126
|
exec(code, module.__dict__)
|
|
127
|
+
|
|
128
|
+
tmp_module = module.__dict__.copy()
|
|
129
|
+
main_entypoint_schemas = {}
|
|
130
|
+
for k, v in tmp_module.items():
|
|
131
|
+
# move first schemas to end for correct order import and code generate
|
|
132
|
+
if _is_ssc_cls(k, v):
|
|
133
|
+
main_entypoint_schemas[k] = v
|
|
134
|
+
module.__dict__.pop(k)
|
|
135
|
+
# scan and import sub_schemas
|
|
136
|
+
# NOTE: context will be overrided by BaseSchema-like names
|
|
137
|
+
elif _is_not_dunder_obj(k) and isinstance(v, ModuleType):
|
|
138
|
+
for sc in extract_schemas_from_module(v):
|
|
139
|
+
if module.__dict__.get(sc.__name__):
|
|
140
|
+
LOGGER.warning(
|
|
141
|
+
"Schema `%s` already defined. `%s.%s` override it",
|
|
142
|
+
sc.__name__,
|
|
143
|
+
f"{v.__name__}.{sc.__name__}",
|
|
144
|
+
)
|
|
145
|
+
module.__dict__[sc.__name__] = sc
|
|
146
|
+
|
|
147
|
+
module.__dict__.update(main_entypoint_schemas)
|
|
109
148
|
return module
|
|
@@ -105,7 +105,6 @@ from ssc_codegen.ast_ import (
|
|
|
105
105
|
ExprStringMapReplace,
|
|
106
106
|
ExprListStringMapReplace,
|
|
107
107
|
)
|
|
108
|
-
from ssc_codegen.ast_.nodes_core import ModuleImports
|
|
109
108
|
from ssc_codegen.ast_.nodes_selectors import ExprMapAttrs, ExprMapAttrsAll
|
|
110
109
|
from ssc_codegen.ast_.nodes_string import (
|
|
111
110
|
ExprListStringUnescape,
|
|
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
|