ssc_codegen 0.5.0__tar.gz → 0.5.1__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.5.0 → ssc_codegen-0.5.1}/.idea/workspace.xml +106 -85
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/PKG-INFO +1 -1
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/dart/booksToScrape.dart +7 -7
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/go/booksToScrape.go +81 -46
- ssc_codegen-0.5.1/o.py +8 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/pyproject.toml +1 -1
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/scripts/ver_patch.sh +1 -1
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/__init__.py +1 -1
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/cli.py +10 -6
- ssc_codegen-0.5.1/ssc_codegen/converters/ast_utils.py +45 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/base.py +7 -6
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/go_goquery.py +89 -96
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/templates/go.py +501 -183
- ssc_codegen-0.5.1/ssc_codegen/converters/tools.py +20 -0
- ssc_codegen-0.5.1/ssc_codegen/converters/utils.py +40 -0
- ssc_codegen-0.5.1/tests/utils/test_go_unimport.py +146 -0
- ssc_codegen-0.5.0/examples/_demp.py +0 -12
- ssc_codegen-0.5.0/ssc_codegen/converters/tools.py +0 -2
- ssc_codegen-0.5.0/ssc_codegen/converters/utils.py +0 -81
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.gitignore +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/.gitignore +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/libraries/Dart_Packages.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/libraries/Dart_SDK.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/misc.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/modules.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/selector_schema_codegen.iml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/.idea/vcs.xml +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/LICENSE +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/README.md +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/README.md +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/dart/main.dart +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/generate_code.sh +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/go/main.go +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/js/booksToScrape.js +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/js/main.js +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/manual_make.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/python/booksToScrape.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/python/main.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/runtime_compile.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/examples/schemas/booksToScrape.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/main.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/scripts/check.sh +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/scripts/fix.sh +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/scripts/version.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/ast_builder.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/ast_ssc.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/cli_utils.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/compiler.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/consts.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/__init__.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/dart_universal_html.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/js_pure.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/py_base.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/py_bs4.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/py_parsel.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/py_scrapy.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/py_selectolax.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/templates/dart.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/templates/js.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/templates/py.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/converters/templates/utils.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/document.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/document_utlis.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/schema.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/selector_utils.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/ssc_codegen/tokens.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/config.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/converter_tools/test_str_utils.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/converter_tools/test_variable.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/demo.html +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_array.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_assert.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_invalid_expr.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_regex.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_select.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_document_text.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/document/test_nested.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/schema/test_sc_magic_methods.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/schema/test_sc_mro.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/utils/test_convert_query.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/tests/utils/test_validate_query.py +0 -0
- {ssc_codegen-0.5.0 → ssc_codegen-0.5.1}/uv.lock +0 -0
|
@@ -4,9 +4,16 @@
|
|
|
4
4
|
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
|
-
<list default="true" id="9c5efa3e-dda3-4c3a-8055-fa28924643ed" name="Changes" comment="add
|
|
7
|
+
<list default="true" id="9c5efa3e-dda3-4c3a-8055-fa28924643ed" name="Changes" comment="is_optional_variable: add optional value check">
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
|
9
|
-
<change beforePath="$PROJECT_DIR$/
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/examples/dart/booksToScrape.dart" beforeDir="false" afterPath="$PROJECT_DIR$/examples/dart/booksToScrape.dart" afterDir="false" />
|
|
10
|
+
<change beforePath="$PROJECT_DIR$/examples/go/booksToScrape.go" beforeDir="false" afterPath="$PROJECT_DIR$/examples/go/booksToScrape.go" afterDir="false" />
|
|
11
|
+
<change beforePath="$PROJECT_DIR$/examples/js/booksToScrape.js" beforeDir="false" afterPath="$PROJECT_DIR$/examples/js/booksToScrape.js" afterDir="false" />
|
|
12
|
+
<change beforePath="$PROJECT_DIR$/examples/python/booksToScrape.py" beforeDir="false" afterPath="$PROJECT_DIR$/examples/python/booksToScrape.py" afterDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/examples/schemas/booksToScrape.py" beforeDir="false" afterPath="$PROJECT_DIR$/examples/schemas/booksToScrape.py" afterDir="false" />
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/ssc_codegen/converters/base.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssc_codegen/converters/base.py" afterDir="false" />
|
|
15
|
+
<change beforePath="$PROJECT_DIR$/ssc_codegen/converters/go_goquery.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssc_codegen/converters/go_goquery.py" afterDir="false" />
|
|
16
|
+
<change beforePath="$PROJECT_DIR$/ssc_codegen/converters/templates/go.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssc_codegen/converters/templates/go.py" afterDir="false" />
|
|
10
17
|
</list>
|
|
11
18
|
<option name="SHOW_DIALOG" value="false" />
|
|
12
19
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -96,6 +103,7 @@
|
|
|
96
103
|
"Python tests.Python tests for test_document_select.test_document_to_list_document.executor": "Run",
|
|
97
104
|
"Python tests.Python tests for test_document_text.test_fail_str_format.executor": "Run",
|
|
98
105
|
"Python tests.Python tests for test_document_text.test_string_expr.executor": "Run",
|
|
106
|
+
"Python tests.Python tests for test_go_unimport.test_go_unimport_naive.executor": "Run",
|
|
99
107
|
"Python tests.Python tests for test_invalid_expr.test_invalid_doc_expr.executor": "Run",
|
|
100
108
|
"Python tests.Python tests for test_invalid_expr.test_invalid_expr.executor": "Run",
|
|
101
109
|
"Python tests.Python tests for test_nested.test_nested.executor": "Run",
|
|
@@ -161,7 +169,7 @@
|
|
|
161
169
|
"WebServerToolWindowFactoryState": "false",
|
|
162
170
|
"dart.analysis.tool.window.visible": "false",
|
|
163
171
|
"git-widget-placeholder": "main",
|
|
164
|
-
"last_opened_file_path": "/home/georgiy/PycharmProjects/selector_schema_codegen",
|
|
172
|
+
"last_opened_file_path": "/home/georgiy/PycharmProjects/selector_schema_codegen/ssc_codegen/converters/ast_utils.py",
|
|
165
173
|
"node.js.detected.package.eslint": "true",
|
|
166
174
|
"node.js.detected.package.tslint": "true",
|
|
167
175
|
"node.js.selected.package.eslint": "(autodetect)",
|
|
@@ -183,47 +191,54 @@
|
|
|
183
191
|
<recent name="$PROJECT_DIR$/ssc_codegen/converters/templates/dart/universal_html" />
|
|
184
192
|
</key>
|
|
185
193
|
<key name="MoveFile.RECENT_KEYS">
|
|
194
|
+
<recent name="$PROJECT_DIR$/ssc_codegen/converters" />
|
|
186
195
|
<recent name="$PROJECT_DIR$/examples" />
|
|
187
196
|
<recent name="$PROJECT_DIR$/examples/python" />
|
|
188
197
|
<recent name="$PROJECT_DIR$/tests/document" />
|
|
189
198
|
<recent name="$PROJECT_DIR$/scripts" />
|
|
190
|
-
<recent name="$PROJECT_DIR$/ssc_codegen" />
|
|
191
199
|
</key>
|
|
192
200
|
</component>
|
|
193
|
-
<component name="RunManager" selected="Python
|
|
194
|
-
<configuration name="
|
|
201
|
+
<component name="RunManager" selected="Python.o">
|
|
202
|
+
<configuration name="o" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
|
195
203
|
<module name="selector_schema_codegen" />
|
|
196
204
|
<option name="ENV_FILES" value="" />
|
|
197
205
|
<option name="INTERPRETER_OPTIONS" value="" />
|
|
198
206
|
<option name="PARENT_ENVS" value="true" />
|
|
207
|
+
<envs>
|
|
208
|
+
<env name="PYTHONUNBUFFERED" value="1" />
|
|
209
|
+
</envs>
|
|
199
210
|
<option name="SDK_HOME" value="" />
|
|
200
|
-
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR
|
|
211
|
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
201
212
|
<option name="IS_MODULE_SDK" value="true" />
|
|
202
213
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
|
203
214
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
204
215
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
|
205
|
-
<option name="
|
|
206
|
-
<option name="
|
|
207
|
-
<option name="
|
|
216
|
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/o.py" />
|
|
217
|
+
<option name="PARAMETERS" value="" />
|
|
218
|
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
|
219
|
+
<option name="EMULATE_TERMINAL" value="false" />
|
|
220
|
+
<option name="MODULE_MODE" value="false" />
|
|
221
|
+
<option name="REDIRECT_INPUT" value="false" />
|
|
222
|
+
<option name="INPUT_FILE" value="" />
|
|
208
223
|
<method v="2" />
|
|
209
224
|
</configuration>
|
|
210
|
-
<configuration name="Python tests for
|
|
225
|
+
<configuration name="Python tests for test_go_unimport.test_go_unimport_naive" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
|
|
211
226
|
<module name="selector_schema_codegen" />
|
|
212
227
|
<option name="ENV_FILES" value="" />
|
|
213
228
|
<option name="INTERPRETER_OPTIONS" value="" />
|
|
214
229
|
<option name="PARENT_ENVS" value="true" />
|
|
215
230
|
<option name="SDK_HOME" value="" />
|
|
216
|
-
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests/
|
|
231
|
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests/utils" />
|
|
217
232
|
<option name="IS_MODULE_SDK" value="true" />
|
|
218
233
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
|
219
234
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
220
235
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
|
221
236
|
<option name="_new_additionalArguments" value="""" />
|
|
222
|
-
<option name="_new_target" value=""
|
|
237
|
+
<option name="_new_target" value=""test_go_unimport.test_go_unimport_naive"" />
|
|
223
238
|
<option name="_new_targetType" value=""PYTHON"" />
|
|
224
239
|
<method v="2" />
|
|
225
240
|
</configuration>
|
|
226
|
-
<configuration name="Python tests for test_sc_magic_methods.
|
|
241
|
+
<configuration name="Python tests for test_sc_magic_methods.test_fail_field_empty_expr" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
|
|
227
242
|
<module name="selector_schema_codegen" />
|
|
228
243
|
<option name="ENV_FILES" value="" />
|
|
229
244
|
<option name="INTERPRETER_OPTIONS" value="" />
|
|
@@ -235,7 +250,7 @@
|
|
|
235
250
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
236
251
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
|
237
252
|
<option name="_new_additionalArguments" value="""" />
|
|
238
|
-
<option name="_new_target" value=""test_sc_magic_methods.
|
|
253
|
+
<option name="_new_target" value=""test_sc_magic_methods.test_fail_field_empty_expr"" />
|
|
239
254
|
<option name="_new_targetType" value=""PYTHON"" />
|
|
240
255
|
<method v="2" />
|
|
241
256
|
</configuration>
|
|
@@ -273,11 +288,11 @@
|
|
|
273
288
|
</configuration>
|
|
274
289
|
<recent_temporary>
|
|
275
290
|
<list>
|
|
291
|
+
<item itemvalue="Python.o" />
|
|
292
|
+
<item itemvalue="Python tests.Python tests for test_go_unimport.test_go_unimport_naive" />
|
|
276
293
|
<item itemvalue="Python tests.Python tests in tests" />
|
|
277
294
|
<item itemvalue="Python tests.Python tests for test_sc_mro.test_schema_mro" />
|
|
278
295
|
<item itemvalue="Python tests.Python tests for test_sc_magic_methods.test_fail_field_empty_expr" />
|
|
279
|
-
<item itemvalue="Python tests.Python tests for test_sc_magic_methods.test_fail_schema_split_doc_ret_type" />
|
|
280
|
-
<item itemvalue="Python tests.Python tests for test_sc_magic_methods.test_fail_schema_magic" />
|
|
281
296
|
</list>
|
|
282
297
|
</recent_temporary>
|
|
283
298
|
</component>
|
|
@@ -359,63 +374,8 @@
|
|
|
359
374
|
<workItem from="1738140404247" duration="31892000" />
|
|
360
375
|
<workItem from="1738225459572" duration="22561000" />
|
|
361
376
|
<workItem from="1738270110515" duration="2424000" />
|
|
362
|
-
<workItem from="1738301565437" duration="
|
|
363
|
-
|
|
364
|
-
<task id="LOCAL-00109" summary="python: update defaultwrapper to default_start, default_end opcodes">
|
|
365
|
-
<option name="closed" value="true" />
|
|
366
|
-
<created>1735405760611</created>
|
|
367
|
-
<option name="number" value="00109" />
|
|
368
|
-
<option name="presentableId" value="LOCAL-00109" />
|
|
369
|
-
<option name="project" value="LOCAL" />
|
|
370
|
-
<updated>1735405760611</updated>
|
|
371
|
-
</task>
|
|
372
|
-
<task id="LOCAL-00110" summary="__StructNode: fix ret_type in default wrapper case fix Optional type in default wrapper, refactoring build_ast_struct, extend debug comment info in STRUCT_PARSE_START node">
|
|
373
|
-
<option name="closed" value="true" />
|
|
374
|
-
<created>1735410960487</created>
|
|
375
|
-
<option name="number" value="00110" />
|
|
376
|
-
<option name="presentableId" value="LOCAL-00110" />
|
|
377
|
-
<option name="project" value="LOCAL" />
|
|
378
|
-
<updated>1735410960487</updated>
|
|
379
|
-
</task>
|
|
380
|
-
<task id="LOCAL-00111" summary="fix StructType.FLAT_LIST type gen, add INT, FLOAT types TYPES">
|
|
381
|
-
<option name="closed" value="true" />
|
|
382
|
-
<created>1735410993265</created>
|
|
383
|
-
<option name="number" value="00111" />
|
|
384
|
-
<option name="presentableId" value="LOCAL-00111" />
|
|
385
|
-
<option name="project" value="LOCAL" />
|
|
386
|
-
<updated>1735410993265</updated>
|
|
387
|
-
</task>
|
|
388
|
-
<task id="LOCAL-00112" summary="refactoring converter node visitor, debug token writer">
|
|
389
|
-
<option name="closed" value="true" />
|
|
390
|
-
<created>1735415929769</created>
|
|
391
|
-
<option name="number" value="00112" />
|
|
392
|
-
<option name="presentableId" value="LOCAL-00112" />
|
|
393
|
-
<option name="project" value="LOCAL" />
|
|
394
|
-
<updated>1735415929769</updated>
|
|
395
|
-
</task>
|
|
396
|
-
<task id="LOCAL-00113" summary="add TemplateBindings abstraction for increase readability converters">
|
|
397
|
-
<option name="closed" value="true" />
|
|
398
|
-
<created>1735487754529</created>
|
|
399
|
-
<option name="number" value="00113" />
|
|
400
|
-
<option name="presentableId" value="LOCAL-00113" />
|
|
401
|
-
<option name="project" value="LOCAL" />
|
|
402
|
-
<updated>1735487754530</updated>
|
|
403
|
-
</task>
|
|
404
|
-
<task id="LOCAL-00114" summary="refactoring python codegen by TemplateBindings">
|
|
405
|
-
<option name="closed" value="true" />
|
|
406
|
-
<created>1735487822398</created>
|
|
407
|
-
<option name="number" value="00114" />
|
|
408
|
-
<option name="presentableId" value="LOCAL-00114" />
|
|
409
|
-
<option name="project" value="LOCAL" />
|
|
410
|
-
<updated>1735487822398</updated>
|
|
411
|
-
</task>
|
|
412
|
-
<task id="LOCAL-00115" summary="update T_TEMPLATE_BIND, T_TEMPLATE_BIND types">
|
|
413
|
-
<option name="closed" value="true" />
|
|
414
|
-
<created>1735492094025</created>
|
|
415
|
-
<option name="number" value="00115" />
|
|
416
|
-
<option name="presentableId" value="LOCAL-00115" />
|
|
417
|
-
<option name="project" value="LOCAL" />
|
|
418
|
-
<updated>1735492094025</updated>
|
|
377
|
+
<workItem from="1738301565437" duration="8521000" />
|
|
378
|
+
<workItem from="1738575037148" duration="21410000" />
|
|
419
379
|
</task>
|
|
420
380
|
<task id="LOCAL-00116" summary="refactoring js_pure codegen">
|
|
421
381
|
<option name="closed" value="true" />
|
|
@@ -753,7 +713,63 @@
|
|
|
753
713
|
<option name="project" value="LOCAL" />
|
|
754
714
|
<updated>1738342137302</updated>
|
|
755
715
|
</task>
|
|
756
|
-
<
|
|
716
|
+
<task id="LOCAL-00158" summary="refactoring: ast utils to another module">
|
|
717
|
+
<option name="closed" value="true" />
|
|
718
|
+
<created>1738579872551</created>
|
|
719
|
+
<option name="number" value="00158" />
|
|
720
|
+
<option name="presentableId" value="LOCAL-00158" />
|
|
721
|
+
<option name="project" value="LOCAL" />
|
|
722
|
+
<updated>1738579872552</updated>
|
|
723
|
+
</task>
|
|
724
|
+
<task id="LOCAL-00159" summary="refactoring: ast utils to another module">
|
|
725
|
+
<option name="closed" value="true" />
|
|
726
|
+
<created>1738579884231</created>
|
|
727
|
+
<option name="number" value="00159" />
|
|
728
|
+
<option name="presentableId" value="LOCAL-00159" />
|
|
729
|
+
<option name="project" value="LOCAL" />
|
|
730
|
+
<updated>1738579884231</updated>
|
|
731
|
+
</task>
|
|
732
|
+
<task id="LOCAL-00160" summary="gen_go: add unimport function. fix typo --debug flag">
|
|
733
|
+
<option name="closed" value="true" />
|
|
734
|
+
<created>1738579935707</created>
|
|
735
|
+
<option name="number" value="00160" />
|
|
736
|
+
<option name="presentableId" value="LOCAL-00160" />
|
|
737
|
+
<option name="project" value="LOCAL" />
|
|
738
|
+
<updated>1738579935707</updated>
|
|
739
|
+
</task>
|
|
740
|
+
<task id="LOCAL-00161" summary="go unimport tests">
|
|
741
|
+
<option name="closed" value="true" />
|
|
742
|
+
<created>1738579946477</created>
|
|
743
|
+
<option name="number" value="00161" />
|
|
744
|
+
<option name="presentableId" value="LOCAL-00161" />
|
|
745
|
+
<option name="project" value="LOCAL" />
|
|
746
|
+
<updated>1738579946477</updated>
|
|
747
|
+
</task>
|
|
748
|
+
<task id="LOCAL-00162" summary="change backend build to hatchling">
|
|
749
|
+
<option name="closed" value="true" />
|
|
750
|
+
<created>1738579975358</created>
|
|
751
|
+
<option name="number" value="00162" />
|
|
752
|
+
<option name="presentableId" value="LOCAL-00162" />
|
|
753
|
+
<option name="project" value="LOCAL" />
|
|
754
|
+
<updated>1738579975358</updated>
|
|
755
|
+
</task>
|
|
756
|
+
<task id="LOCAL-00163" summary="go_unimport_naive: remove whitespace">
|
|
757
|
+
<option name="closed" value="true" />
|
|
758
|
+
<created>1738580478169</created>
|
|
759
|
+
<option name="number" value="00163" />
|
|
760
|
+
<option name="presentableId" value="LOCAL-00163" />
|
|
761
|
+
<option name="project" value="LOCAL" />
|
|
762
|
+
<updated>1738580478169</updated>
|
|
763
|
+
</task>
|
|
764
|
+
<task id="LOCAL-00164" summary="is_optional_variable: add optional value check">
|
|
765
|
+
<option name="closed" value="true" />
|
|
766
|
+
<created>1738621734629</created>
|
|
767
|
+
<option name="number" value="00164" />
|
|
768
|
+
<option name="presentableId" value="LOCAL-00164" />
|
|
769
|
+
<option name="project" value="LOCAL" />
|
|
770
|
+
<updated>1738621734629</updated>
|
|
771
|
+
</task>
|
|
772
|
+
<option name="localTasksCounter" value="165" />
|
|
757
773
|
<servers />
|
|
758
774
|
</component>
|
|
759
775
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -771,12 +787,6 @@
|
|
|
771
787
|
</option>
|
|
772
788
|
</component>
|
|
773
789
|
<component name="VcsManagerConfiguration">
|
|
774
|
-
<MESSAGE value="fix dart codegen" />
|
|
775
|
-
<MESSAGE value="fix XPATH js" />
|
|
776
|
-
<MESSAGE value="add test for converter utils, fix lowerCamelCase func" />
|
|
777
|
-
<MESSAGE value="CallStructFunctionExpression: fix have_default_expr method, DefaultValueWrapper: change accept_type, ret_type to VariableType.DOCUMENT" />
|
|
778
|
-
<MESSAGE value="SIGNATURE_MAP: add ANY, OPTIONAL_INT, OPTIONAL_LIST_INT, OPTIONAL_FLOAT, OPTIONAL_LIST_FLOAT" />
|
|
779
|
-
<MESSAGE value="first works codegen release" />
|
|
780
790
|
<MESSAGE value="refactoring debug callback, extend left_right_var_names docstring" />
|
|
781
791
|
<MESSAGE value="ruff fmt" />
|
|
782
792
|
<MESSAGE value="bump" />
|
|
@@ -796,7 +806,13 @@
|
|
|
796
806
|
<MESSAGE value="update readme" />
|
|
797
807
|
<MESSAGE value="add schema tests" />
|
|
798
808
|
<MESSAGE value="add check stacks expr len, extract_default_expr check stack len throw error if stack is empty" />
|
|
799
|
-
<
|
|
809
|
+
<MESSAGE value="refactoring: ast utils to another module" />
|
|
810
|
+
<MESSAGE value="gen_go: add unimport function. fix typo --debug flag" />
|
|
811
|
+
<MESSAGE value="go unimport tests" />
|
|
812
|
+
<MESSAGE value="change backend build to hatchling" />
|
|
813
|
+
<MESSAGE value="go_unimport_naive: remove whitespace" />
|
|
814
|
+
<MESSAGE value="is_optional_variable: add optional value check" />
|
|
815
|
+
<option name="LAST_COMMIT_MESSAGE" value="is_optional_variable: add optional value check" />
|
|
800
816
|
</component>
|
|
801
817
|
<component name="XDebuggerManager">
|
|
802
818
|
<breakpoint-manager>
|
|
@@ -821,6 +837,11 @@
|
|
|
821
837
|
<line>62</line>
|
|
822
838
|
<option name="timeStamp" value="117" />
|
|
823
839
|
</line-breakpoint>
|
|
840
|
+
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
|
841
|
+
<url>file://$PROJECT_DIR$/ssc_codegen/converters/tools.py</url>
|
|
842
|
+
<line>16</line>
|
|
843
|
+
<option name="timeStamp" value="121" />
|
|
844
|
+
</line-breakpoint>
|
|
824
845
|
<line-breakpoint enabled="true" type="Dart">
|
|
825
846
|
<url>file://$PROJECT_DIR$/dart_sscgen/bin/dart_sscgen.dart</url>
|
|
826
847
|
<line>16</line>
|
|
@@ -830,11 +851,11 @@
|
|
|
830
851
|
</breakpoint-manager>
|
|
831
852
|
</component>
|
|
832
853
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
|
833
|
-
<SUITE FILE_PATH="coverage/selector_schema_codegen$.coverage" NAME=" Coverage Results" MODIFIED="
|
|
854
|
+
<SUITE FILE_PATH="coverage/selector_schema_codegen$.coverage" NAME=" Coverage Results" MODIFIED="1738580416414" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests/utils" />
|
|
834
855
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$cli.coverage" NAME="cli Coverage Results" MODIFIED="1717347870433" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
|
835
856
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$schemas.coverage" NAME="schemas Coverage Results" MODIFIED="1714992167313" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen/v2" />
|
|
836
|
-
<SUITE FILE_PATH="coverage/selector_schema_codegen$calc_hash.coverage" NAME="calc_hash Coverage Results" MODIFIED="1718171677863" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen/utils" />
|
|
837
857
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$extract.coverage" NAME="validate Coverage Results" MODIFIED="1706819346637" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2" />
|
|
858
|
+
<SUITE FILE_PATH="coverage/selector_schema_codegen$calc_hash.coverage" NAME="calc_hash Coverage Results" MODIFIED="1718171677863" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen/utils" />
|
|
838
859
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$ast_ssc.coverage" NAME="ast_ssc Coverage Results" MODIFIED="1735321217497" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen" />
|
|
839
860
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$translator.coverage" NAME="translator Coverage Results" MODIFIED="1707045679760" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2" />
|
|
840
861
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$constants.coverage" NAME="constants Coverage Results" MODIFIED="1717348468280" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2/schema" />
|
|
@@ -851,7 +872,7 @@
|
|
|
851
872
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$animego_pro.coverage" NAME="animego_pro Coverage Results" MODIFIED="1717401685023" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/libanime_schema/source_v2/src" />
|
|
852
873
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$manual_make.coverage" NAME="manual_make Coverage Results" MODIFIED="1738237757130" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/examples" />
|
|
853
874
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$__init__.coverage" NAME="__init__ Coverage Results" MODIFIED="1715378131584" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2/document" />
|
|
854
|
-
<SUITE FILE_PATH="coverage/selector_schema_codegen$o.coverage" NAME="o Coverage Results" MODIFIED="
|
|
875
|
+
<SUITE FILE_PATH="coverage/selector_schema_codegen$o.coverage" NAME="o Coverage Results" MODIFIED="1738580425453" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
|
855
876
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$aaaa.coverage" NAME="aaaa Coverage Results" MODIFIED="1717773815300" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
|
856
877
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$security.coverage" NAME="security Coverage Results" MODIFIED="1718171942762" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen/utils" />
|
|
857
878
|
<SUITE FILE_PATH="coverage/selector_schema_codegen$raw_main.coverage" NAME="main_raw Coverage Results" MODIFIED="1735415395091" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/examples" />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ssc_codegen
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Add your description here
|
|
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
|
|
@@ -80,15 +80,15 @@ class UrlsMap {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
_parseKey(value) {
|
|
83
|
-
var value1 = value?.
|
|
84
|
-
|
|
85
|
-
value1.replaceFirst(RegExp("^ "), "").replaceFirst(RegExp(" \$"), "");
|
|
86
|
-
return value2;
|
|
83
|
+
var value1 = value?.attributes['href'];
|
|
84
|
+
return value1;
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
_parseValue(value) {
|
|
90
|
-
var value1 = value?.
|
|
91
|
-
|
|
88
|
+
var value1 = value.querySelector("html")?.innerHtml;
|
|
89
|
+
var value2 =
|
|
90
|
+
value1.replaceFirst(RegExp("^ "), "").replaceFirst(RegExp(" \$"), "");
|
|
91
|
+
return value2;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
TUrlsMap parse() {
|
|
@@ -163,7 +163,7 @@ class Books {
|
|
|
163
163
|
var value5 = int.parse(value4!);
|
|
164
164
|
return value5;
|
|
165
165
|
} catch (_) {
|
|
166
|
-
return
|
|
166
|
+
return 0;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -7,7 +7,6 @@ import (
|
|
|
7
7
|
"fmt"
|
|
8
8
|
"github.com/PuerkitoBio/goquery"
|
|
9
9
|
"regexp"
|
|
10
|
-
"slices"
|
|
11
10
|
"strconv"
|
|
12
11
|
"strings"
|
|
13
12
|
)
|
|
@@ -37,21 +36,28 @@ type TCataloguePage struct {
|
|
|
37
36
|
// ]
|
|
38
37
|
type Urls struct{ Document *goquery.Document }
|
|
39
38
|
|
|
40
|
-
func (p *Urls) splitDoc(value *goquery.Selection) *goquery.Selection {
|
|
39
|
+
func (p *Urls) splitDoc(value *goquery.Selection) (*goquery.Selection, error) {
|
|
41
40
|
value1 := value.Find("a")
|
|
42
|
-
return value1
|
|
41
|
+
return value1, nil
|
|
43
42
|
}
|
|
44
|
-
func (p *Urls) parseItem(value *goquery.Selection) string {
|
|
43
|
+
func (p *Urls) parseItem(value *goquery.Selection) (string, error) {
|
|
45
44
|
value1, isExists := value.Attr("href")
|
|
46
45
|
if !isExists {
|
|
47
|
-
|
|
46
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "href", value)
|
|
48
47
|
}
|
|
49
|
-
return value1
|
|
48
|
+
return value1, nil
|
|
50
49
|
}
|
|
51
50
|
func (p *Urls) Parse() (*TUrls, error) {
|
|
52
51
|
items := make(TUrls, 0)
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
docParts, err := p.splitDoc(p.Document.Selection)
|
|
53
|
+
if err != nil {
|
|
54
|
+
return nil, err
|
|
55
|
+
}
|
|
56
|
+
for _, i := range docParts.EachIter() {
|
|
57
|
+
rawItem, err := p.parseItem(i)
|
|
58
|
+
if err != nil {
|
|
59
|
+
return nil, err
|
|
60
|
+
}
|
|
55
61
|
items = append(items, rawItem)
|
|
56
62
|
}
|
|
57
63
|
return &items, nil
|
|
@@ -65,27 +71,40 @@ func (p *Urls) Parse() (*TUrls, error) {
|
|
|
65
71
|
// }
|
|
66
72
|
type UrlsMap struct{ Document *goquery.Document }
|
|
67
73
|
|
|
68
|
-
func (p *UrlsMap) splitDoc(value *goquery.Selection) *goquery.Selection {
|
|
74
|
+
func (p *UrlsMap) splitDoc(value *goquery.Selection) (*goquery.Selection, error) {
|
|
69
75
|
value1 := value.Find("a")
|
|
70
|
-
return value1
|
|
76
|
+
return value1, nil
|
|
71
77
|
}
|
|
72
|
-
func (p *UrlsMap) parseKey(value *goquery.Selection) string {
|
|
78
|
+
func (p *UrlsMap) parseKey(value *goquery.Selection) (string, error) {
|
|
73
79
|
value1, isExists := value.Attr("href")
|
|
74
80
|
if !isExists {
|
|
75
|
-
|
|
81
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "href", value)
|
|
76
82
|
}
|
|
77
|
-
return value1
|
|
83
|
+
return value1, nil
|
|
78
84
|
}
|
|
79
|
-
func (p *UrlsMap) parseValue(value *goquery.Selection) string {
|
|
80
|
-
value1,
|
|
85
|
+
func (p *UrlsMap) parseValue(value *goquery.Selection) (string, error) {
|
|
86
|
+
value1, err := value.Html()
|
|
87
|
+
if err != nil {
|
|
88
|
+
return "", err
|
|
89
|
+
}
|
|
81
90
|
value2 := strings.Trim(" ", value1)
|
|
82
|
-
return value2
|
|
91
|
+
return value2, nil
|
|
83
92
|
}
|
|
84
93
|
func (p *UrlsMap) Parse() (*TUrlsMap, error) {
|
|
85
94
|
items := make(TUrlsMap)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
docParts, err := p.splitDoc(p.Document.Selection)
|
|
96
|
+
if err != nil {
|
|
97
|
+
return nil, err
|
|
98
|
+
}
|
|
99
|
+
for _, i := range docParts.EachIter() {
|
|
100
|
+
keyRaw, err := p.parseKey(i)
|
|
101
|
+
if err != nil {
|
|
102
|
+
return nil, err
|
|
103
|
+
}
|
|
104
|
+
valueRaw, err := p.parseValue(i)
|
|
105
|
+
if err != nil {
|
|
106
|
+
return nil, err
|
|
107
|
+
}
|
|
89
108
|
items[keyRaw] = valueRaw
|
|
90
109
|
}
|
|
91
110
|
return &items, nil
|
|
@@ -105,43 +124,43 @@ func (p *UrlsMap) Parse() (*TUrlsMap, error) {
|
|
|
105
124
|
// ]
|
|
106
125
|
type Books struct{ Document *goquery.Document }
|
|
107
126
|
|
|
108
|
-
func (p *Books) splitDoc(value *goquery.Selection) *goquery.Selection {
|
|
127
|
+
func (p *Books) splitDoc(value *goquery.Selection) (*goquery.Selection, error) {
|
|
109
128
|
value1 := value.Find(".col-lg-3")
|
|
110
|
-
return value1
|
|
129
|
+
return value1, nil
|
|
111
130
|
}
|
|
112
|
-
func (p *Books) parseName(value *goquery.Selection) string {
|
|
131
|
+
func (p *Books) parseName(value *goquery.Selection) (string, error) {
|
|
113
132
|
value1 := value.Find(".thumbnail").First()
|
|
114
133
|
value2, isExists := value1.Attr("alt")
|
|
115
134
|
if !isExists {
|
|
116
|
-
|
|
135
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "alt", value1)
|
|
117
136
|
}
|
|
118
|
-
return value2
|
|
137
|
+
return value2, nil
|
|
119
138
|
}
|
|
120
|
-
func (p *Books) parseImageUrl(value *goquery.Selection) string {
|
|
139
|
+
func (p *Books) parseImageUrl(value *goquery.Selection) (string, error) {
|
|
121
140
|
value1 := value.Find(".thumbnail").First()
|
|
122
141
|
value2, isExists := value1.Attr("src")
|
|
123
142
|
if !isExists {
|
|
124
|
-
|
|
143
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "src", value1)
|
|
125
144
|
}
|
|
126
145
|
value3 := fmt.Sprintf("https://%s", value2)
|
|
127
|
-
return value3
|
|
146
|
+
return value3, nil
|
|
128
147
|
}
|
|
129
|
-
func (p *Books) parseUrl(value *goquery.Selection) string {
|
|
148
|
+
func (p *Books) parseUrl(value *goquery.Selection) (string, error) {
|
|
130
149
|
value1 := value.Find(".image_container > a").First()
|
|
131
150
|
value2, isExists := value1.Attr("href")
|
|
132
151
|
if !isExists {
|
|
133
|
-
|
|
152
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "href", value1)
|
|
134
153
|
}
|
|
135
|
-
return value2
|
|
154
|
+
return value2, nil
|
|
136
155
|
}
|
|
137
|
-
func (p *Books) parseRating(value *goquery.Selection) string {
|
|
156
|
+
func (p *Books) parseRating(value *goquery.Selection) (string, error) {
|
|
138
157
|
value1 := value.Find(".star-rating").First()
|
|
139
158
|
value2, isExists := value1.Attr("class")
|
|
140
159
|
if !isExists {
|
|
141
|
-
|
|
160
|
+
return "", fmt.Errorf("attr `%s` not exists in `%s`", "class", value1)
|
|
142
161
|
}
|
|
143
162
|
value3 := strings.TrimLeft(value2, "star-rating ")
|
|
144
|
-
return value3
|
|
163
|
+
return value3, nil
|
|
145
164
|
}
|
|
146
165
|
func (p *Books) parsePrice(value *goquery.Selection) (result int, err error) {
|
|
147
166
|
defer func() {
|
|
@@ -162,11 +181,27 @@ func (p *Books) parsePrice(value *goquery.Selection) (result int, err error) {
|
|
|
162
181
|
}
|
|
163
182
|
func (p *Books) Parse() (*TBooksITEMS, error) {
|
|
164
183
|
items := make(TBooksITEMS, 0)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
docParts, err := p.splitDoc(p.Document.Selection)
|
|
185
|
+
if err != nil {
|
|
186
|
+
return nil, err
|
|
187
|
+
}
|
|
188
|
+
for _, i := range docParts.EachIter() {
|
|
189
|
+
NameRaw, err := p.parseName(i)
|
|
190
|
+
if err != nil {
|
|
191
|
+
return nil, err
|
|
192
|
+
}
|
|
193
|
+
ImageUrlRaw, err := p.parseImageUrl(i)
|
|
194
|
+
if err != nil {
|
|
195
|
+
return nil, err
|
|
196
|
+
}
|
|
197
|
+
UrlRaw, err := p.parseUrl(i)
|
|
198
|
+
if err != nil {
|
|
199
|
+
return nil, err
|
|
200
|
+
}
|
|
201
|
+
RatingRaw, err := p.parseRating(i)
|
|
202
|
+
if err != nil {
|
|
203
|
+
return nil, err
|
|
204
|
+
}
|
|
170
205
|
PriceRaw, _ := p.parsePrice(i)
|
|
171
206
|
item := TBooks{NameRaw, ImageUrlRaw, UrlRaw, RatingRaw, PriceRaw}
|
|
172
207
|
items = append(items, item)
|
|
@@ -209,14 +244,14 @@ func (p *Books) Parse() (*TBooksITEMS, error) {
|
|
|
209
244
|
// }
|
|
210
245
|
type CataloguePage struct{ Document *goquery.Document }
|
|
211
246
|
|
|
212
|
-
func (p *CataloguePage) preValidate(value *goquery.Selection) error {
|
|
247
|
+
func (p *CataloguePage) preValidate(value *goquery.Selection) (error, error) {
|
|
213
248
|
value1 := value.Find("title").First()
|
|
214
249
|
value2 := value1.Text()
|
|
215
250
|
_, errValue2 := regexp.Match(`Books to Scrape`, []byte(value2))
|
|
216
251
|
if errValue2 != nil {
|
|
217
|
-
|
|
252
|
+
return nil, fmt.Errorf("")
|
|
218
253
|
}
|
|
219
|
-
return nil
|
|
254
|
+
return nil, nil
|
|
220
255
|
}
|
|
221
256
|
func (p *CataloguePage) parseTitle(value *goquery.Selection) (result string, err error) {
|
|
222
257
|
defer func() {
|
|
@@ -241,7 +276,7 @@ func (p *CataloguePage) parseUrls(value *goquery.Selection) (TUrls, error) {
|
|
|
241
276
|
st0 := Urls{doc0}
|
|
242
277
|
value1, err := st0.Parse()
|
|
243
278
|
if err != nil {
|
|
244
|
-
|
|
279
|
+
return nil, err
|
|
245
280
|
}
|
|
246
281
|
return *value1, nil
|
|
247
282
|
}
|
|
@@ -250,7 +285,7 @@ func (p *CataloguePage) parseUrlsMap(value *goquery.Selection) (TUrlsMap, error)
|
|
|
250
285
|
st0 := UrlsMap{doc0}
|
|
251
286
|
value1, err := st0.Parse()
|
|
252
287
|
if err != nil {
|
|
253
|
-
|
|
288
|
+
return nil, err
|
|
254
289
|
}
|
|
255
290
|
return *value1, nil
|
|
256
291
|
}
|
|
@@ -259,14 +294,14 @@ func (p *CataloguePage) parseBooks(value *goquery.Selection) (TBooksITEMS, error
|
|
|
259
294
|
st0 := Books{doc0}
|
|
260
295
|
value1, err := st0.Parse()
|
|
261
296
|
if err != nil {
|
|
262
|
-
|
|
297
|
+
return nil, err
|
|
263
298
|
}
|
|
264
299
|
return *value1, nil
|
|
265
300
|
}
|
|
266
301
|
func (p *CataloguePage) Parse() (*TCataloguePage, error) {
|
|
267
|
-
err := p.preValidate(p.Document.Selection)
|
|
302
|
+
_, err := p.preValidate(p.Document.Selection)
|
|
268
303
|
if err != nil {
|
|
269
|
-
|
|
304
|
+
return nil, err
|
|
270
305
|
}
|
|
271
306
|
TitleRaw, err := p.parseTitle(p.Document.Selection)
|
|
272
307
|
if err != nil {
|
ssc_codegen-0.5.1/o.py
ADDED
|
@@ -2,7 +2,7 @@ from .document import HTMLDocument, StringDocument, ArrayDocument, AssertDocumen
|
|
|
2
2
|
NumericDocument
|
|
3
3
|
from .schema import ItemSchema, DictSchema, ListSchema, FlatListSchema
|
|
4
4
|
|
|
5
|
-
VERSION = "0.5.
|
|
5
|
+
VERSION = "0.5.1"
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Document(HTMLDocument, StringDocument, ArrayDocument, AssertDocument, DefaultDocument, NumericDocument):
|