ssc_codegen 0.36.1__tar.gz → 0.36.3__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.36.1 → ssc_codegen-0.36.3}/PKG-INFO +1 -1
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/pyproject.toml +1 -1
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/rest.py +9 -1
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/visitor.py +14 -5
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/.gitignore +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/LICENSE +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/README.md +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/_logging.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/array.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/base.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/cast.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/control.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/extract.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/function.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/helpers.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/jsondef.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/module.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/predicate_containers.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/predicate_ops.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/regex.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/rest.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/selectors.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/string.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/struct.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/typedef.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/ast/types.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/contexts.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/expressions.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/format.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/linter.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/module_handler.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/predicates.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/reader.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/rest_artifacts.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/struct_parser.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/core/type_checking.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/exceptions.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/explore.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/generation/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/generation/builder.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/generation/runtime.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/health.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/main.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/naming.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/parsers/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/parsers/curl.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/parsers/http.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/regex_utils.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/request_spec.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/http_libs/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/http_libs/base.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/http_libs/nethttp.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/literals.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/regex.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/golang/runtime.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/http_libs/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/http_libs/axios.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/http_libs/base.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/http_libs/fetch.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/rest.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/visitor.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/profile.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/base.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/bs4.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/lxml.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/parsel.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/html_libs/slax.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/http_libs/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/http_libs/aiohttp.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/http_libs/base.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/http_libs/httpx.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/http_libs/requests.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/rest.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/python/visitor.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/resolver.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/spec.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/traversal/__init__.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/traversal/context.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/traversal/utils.py +0 -0
- {ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/traversal/walker.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.36.
|
|
3
|
+
Version: 0.36.3
|
|
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
|
|
@@ -20,7 +20,9 @@ from ssc_codegen.ast import (
|
|
|
20
20
|
PlaceholderTemplate,
|
|
21
21
|
ResultAliasDef,
|
|
22
22
|
ResultVariantDef,
|
|
23
|
+
Struct,
|
|
23
24
|
StructBase,
|
|
25
|
+
StructType as ST,
|
|
24
26
|
)
|
|
25
27
|
from ssc_codegen.ast.struct import RequestHttp
|
|
26
28
|
from ssc_codegen.naming import to_camel_case, to_pascal_case, to_snake_case
|
|
@@ -338,7 +340,13 @@ def emit_method_fetch(
|
|
|
338
340
|
)
|
|
339
341
|
|
|
340
342
|
# Construct parser from body.
|
|
341
|
-
|
|
343
|
+
# (raw)struct constructor returns a single value (*Name), wrapper
|
|
344
|
+
# signature is (*Name, error) → must add `, nil`. HTML constructor
|
|
345
|
+
# already returns (*Name, error) so naked tuple pass-through works.
|
|
346
|
+
if isinstance(struct, Struct) and struct.type == ST.RAW:
|
|
347
|
+
lines.append(f"{i2}return New{name}(string(body)), nil")
|
|
348
|
+
else:
|
|
349
|
+
lines.append(f"{i2}return New{name}(string(body))")
|
|
342
350
|
lines.append(f"{i1}}}")
|
|
343
351
|
lines.append("")
|
|
344
352
|
return lines
|
|
@@ -138,7 +138,6 @@ from ssc_codegen.naming import (
|
|
|
138
138
|
from ssc_codegen.traversal.utils import (
|
|
139
139
|
find_predicate_container,
|
|
140
140
|
module_has_html_struct,
|
|
141
|
-
module_has_rest,
|
|
142
141
|
module_uses_http,
|
|
143
142
|
)
|
|
144
143
|
from ssc_codegen.generation.builder import ModuleBuilder
|
|
@@ -231,15 +230,17 @@ def _gofmt(source: str) -> str:
|
|
|
231
230
|
if not gofmt:
|
|
232
231
|
return source
|
|
233
232
|
try:
|
|
233
|
+
# Pass UTF-8 explicitly — Windows text-mode defaults to the OEM
|
|
234
|
+
# codepage (cp1251/cp437), corrupting non-ASCII bytes in @doc
|
|
235
|
+
# comments and source strings.
|
|
234
236
|
proc = subprocess.run(
|
|
235
237
|
[gofmt],
|
|
236
|
-
input=source,
|
|
238
|
+
input=source.encode("utf-8"),
|
|
237
239
|
capture_output=True,
|
|
238
|
-
text=True,
|
|
239
240
|
timeout=10,
|
|
240
241
|
)
|
|
241
242
|
if proc.returncode == 0 and proc.stdout:
|
|
242
|
-
return proc.stdout
|
|
243
|
+
return proc.stdout.decode("utf-8")
|
|
243
244
|
except (subprocess.SubprocessError, OSError):
|
|
244
245
|
pass
|
|
245
246
|
return source
|
|
@@ -321,7 +322,7 @@ class GoVisitor(BaseWalker):
|
|
|
321
322
|
for imp in self._builder.std_imports:
|
|
322
323
|
if imp not in self._all_std_imports:
|
|
323
324
|
self._all_std_imports.append(imp)
|
|
324
|
-
if
|
|
325
|
+
if module_uses_http(module_ast):
|
|
325
326
|
self._has_rest = True
|
|
326
327
|
out: dict[str, str] = {"": _gofmt("\n".join(lines))}
|
|
327
328
|
for fname, provider in self._file_providers.items():
|
|
@@ -1358,6 +1359,14 @@ class GoVisitor(BaseWalker):
|
|
|
1358
1359
|
if at and at.base == VT.STRING and not at.is_array:
|
|
1359
1360
|
idx = f"len({ctx.prv})-{abs(i)}" if i < 0 else str(i)
|
|
1360
1361
|
return [f"{ctx.indent}{ctx.nxt} := string({ctx.prv}[{idx}])"]
|
|
1362
|
+
if at and at.base == VT.DOCUMENT:
|
|
1363
|
+
# *goquery.Selection is not indexable in Go — use .Eq().
|
|
1364
|
+
# Negative index → Length() + i (i is negative, e.g. -1 → last).
|
|
1365
|
+
if i < 0:
|
|
1366
|
+
idx = f"{ctx.prv}.Length() + {i}"
|
|
1367
|
+
else:
|
|
1368
|
+
idx = str(i)
|
|
1369
|
+
return [f"{ctx.indent}{ctx.nxt} := {ctx.prv}.Eq({idx})"]
|
|
1361
1370
|
if i < 0:
|
|
1362
1371
|
return [f"{ctx.indent}{ctx.nxt} := {ctx.prv}[len({ctx.prv})+{i}]"]
|
|
1363
1372
|
return [f"{ctx.indent}{ctx.nxt} := {ctx.prv}[{i}]"]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ssc_codegen-0.36.1 → ssc_codegen-0.36.3}/ssc_codegen/targets/javascript/http_libs/__init__.py
RENAMED
|
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
|