ssc_codegen 0.6.0__tar.gz → 0.6.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.
Files changed (132) hide show
  1. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/workspace.xml +125 -65
  2. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/PKG-INFO +1 -1
  3. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/dart/booksToScrape.dart +6 -6
  4. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/go/booksToScrape.go +52 -50
  5. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/js/booksToScrape.js +20 -19
  6. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/python/booksToScrape.py +36 -20
  7. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/quotesToScrapeJs/parser_schema.py +23 -8
  8. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/pyproject.toml +2 -2
  9. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/__init__.py +1 -1
  10. ssc_codegen-0.6.1/ssc_codegen/_compat.py +9 -0
  11. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/ast_ssc.py +11 -0
  12. ssc_codegen-0.6.1/ssc_codegen/cli/__init__.py +0 -0
  13. ssc_codegen-0.6.1/ssc_codegen/cli/cli_callbacks.py +34 -0
  14. {ssc_codegen-0.6.0/ssc_codegen → ssc_codegen-0.6.1/ssc_codegen/cli}/cli_utils.py +13 -66
  15. ssc_codegen-0.6.1/ssc_codegen/cli/consts.py +47 -0
  16. ssc_codegen-0.6.0/ssc_codegen/cli.py → ssc_codegen-0.6.1/ssc_codegen/cli/main.py +66 -81
  17. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/consts.py +14 -2
  18. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/base.py +20 -0
  19. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/dart_universal_html.py +5 -9
  20. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/go_goquery.py +80 -15
  21. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/js_pure.py +3 -3
  22. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/json_to_schema.py +1 -1
  23. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/py_base.py +96 -92
  24. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/py_bs4.py +9 -5
  25. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/py_parsel.py +7 -4
  26. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/py_scrapy.py +9 -5
  27. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/py_selectolax.py +8 -5
  28. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/templates/dart.py +2 -2
  29. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/templates/go.py +5 -87
  30. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/templates/js.py +2 -9
  31. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/templates/py.py +1 -1
  32. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/document.py +5 -5
  33. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/document_utlis.py +5 -3
  34. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/json_struct.py +17 -23
  35. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/schema.py +17 -27
  36. ssc_codegen-0.6.1/ssc_codegen/str_utils.py +81 -0
  37. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/converter_tools/test_str_utils.py +2 -8
  38. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/utils/test_go_unimport.py +1 -1
  39. ssc_codegen-0.6.1/uv.lock +597 -0
  40. ssc_codegen-0.6.0/ssc_codegen/converters/tools.py +0 -24
  41. ssc_codegen-0.6.0/ssc_codegen/converters/utils.py +0 -47
  42. ssc_codegen-0.6.0/test_dart/.dart_tool/package_config.json +0 -326
  43. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.gitignore +0 -0
  44. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/.gitignore +0 -0
  45. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/dbnavigator.xml +0 -0
  46. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/discord.xml +0 -0
  47. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  48. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/libraries/Dart_SDK.xml +0 -0
  49. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/misc.xml +0 -0
  50. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/modules.xml +0 -0
  51. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/poetry.xml +0 -0
  52. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/selector_schema_codegen.iml +0 -0
  53. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/.idea/vcs.xml +0 -0
  54. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/LICENSE +0 -0
  55. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/README.md +0 -0
  56. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/docs/index.md +0 -0
  57. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/README.md +0 -0
  58. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/dart/main.dart +0 -0
  59. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/generate_code.sh +0 -0
  60. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/go/main.go +0 -0
  61. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/js/main.js +0 -0
  62. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/manual_make.py +0 -0
  63. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/python/main.py +0 -0
  64. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/python/main2.py +0 -0
  65. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/runtime_compile.py +0 -0
  66. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/booksToScrape/schemas/booksToScrape.py +0 -0
  67. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/quotesToScrapeJs/index.html +0 -0
  68. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/quotesToScrapeJs/main.py +0 -0
  69. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/quotesToScrapeJs/schema.py +0 -0
  70. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/1_basic/index.html +0 -0
  71. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/1_basic/main.py +0 -0
  72. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/1_basic/parser_schema.py +0 -0
  73. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/1_basic/schema.py +0 -0
  74. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/2_string_operations/index.html +0 -0
  75. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/2_string_operations/main.py +0 -0
  76. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/2_string_operations/parser_schema.py +0 -0
  77. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/2_string_operations/schema.py +0 -0
  78. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/3_default_values/index.html +0 -0
  79. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/3_default_values/main.py +0 -0
  80. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/3_default_values/parser_schema.py +0 -0
  81. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/3_default_values/schema.py +0 -0
  82. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/4_validation/bad_index.html +0 -0
  83. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/4_validation/index.html +0 -0
  84. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/4_validation/main.py +0 -0
  85. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/4_validation/parser_schema.py +0 -0
  86. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/4_validation/schema.py +0 -0
  87. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/5_schema_types/index.html +0 -0
  88. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/5_schema_types/main.py +0 -0
  89. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/5_schema_types/parser_schema.py +0 -0
  90. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/5_schema_types/schema.py +0 -0
  91. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/6_nested_schemas/index.html +0 -0
  92. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/6_nested_schemas/main.py +0 -0
  93. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/6_nested_schemas/parser_schema.py +0 -0
  94. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/6_nested_schemas/schema.py +0 -0
  95. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/index.html +0 -0
  96. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/main.py +0 -0
  97. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/parser_schema.py +0 -0
  98. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/raw_json.json +0 -0
  99. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/schema.py +0 -0
  100. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/7_json_extract/template_json_schema.py +0 -0
  101. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/examples/tutorial/readme.md +0 -0
  102. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/main.py +0 -0
  103. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/scripts/check.sh +0 -0
  104. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/scripts/fix.sh +0 -0
  105. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/scripts/ver_patch.sh +0 -0
  106. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/scripts/version.py +0 -0
  107. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/ast_build_utils.py +0 -0
  108. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/ast_builder.py +0 -0
  109. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/compiler.py +0 -0
  110. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/__init__.py +0 -0
  111. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/converters/ast_utils.py +0 -0
  112. /ssc_codegen-0.6.0/ssc_codegen/converters/templates/utils.py → /ssc_codegen-0.6.1/ssc_codegen/converters/templates/template_bindings.py +0 -0
  113. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/selector_utils.py +0 -0
  114. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/ssc_codegen/tokens.py +0 -0
  115. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/converter_tools/test_variable.py +0 -0
  116. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/converters/helpers_converters.py +0 -0
  117. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/converters/test_buildin_converters.py +0 -0
  118. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/converters/test_json_converter.py +0 -0
  119. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_array.py +0 -0
  120. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_assert.py +0 -0
  121. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_invalid_expr.py +0 -0
  122. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_regex.py +0 -0
  123. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_select.py +0 -0
  124. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_document_text.py +0 -0
  125. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_nested.py +0 -0
  126. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/document/test_selector_converters.py +0 -0
  127. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/schema/helpers.py +0 -0
  128. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/schema/test_default_expr.py +0 -0
  129. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/schema/test_sc_magic_methods.py +0 -0
  130. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/schema/test_sc_mro.py +0 -0
  131. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/utils/test_convert_query.py +0 -0
  132. {ssc_codegen-0.6.0 → ssc_codegen-0.6.1}/tests/utils/test_validate_query.py +0 -0
@@ -4,8 +4,15 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="456825a3-1a86-45b6-8506-2bf35bbc9370" name="Changes" comment="generated code">
8
- <change beforePath="$PROJECT_DIR$/ssc_codegen/consts.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssc_codegen/consts.py" afterDir="false" />
7
+ <list default="true" id="456825a3-1a86-45b6-8506-2bf35bbc9370" name="Changes" comment="refactoring TYPEDEF, TYPEDEF_FIELD,">
8
+ <change afterPath="$PROJECT_DIR$/uv.lock" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/examples/booksToScrape/dart/booksToScrape.dart" beforeDir="false" afterPath="$PROJECT_DIR$/examples/booksToScrape/dart/booksToScrape.dart" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/examples/booksToScrape/go/booksToScrape.go" beforeDir="false" afterPath="$PROJECT_DIR$/examples/booksToScrape/go/booksToScrape.go" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/examples/booksToScrape/js/booksToScrape.js" beforeDir="false" afterPath="$PROJECT_DIR$/examples/booksToScrape/js/booksToScrape.js" afterDir="false" />
12
+ <change beforePath="$PROJECT_DIR$/examples/booksToScrape/python/booksToScrape.py" beforeDir="false" afterPath="$PROJECT_DIR$/examples/booksToScrape/python/booksToScrape.py" afterDir="false" />
13
+ <change beforePath="$PROJECT_DIR$/examples/quotesToScrapeJs/parser_schema.py" beforeDir="false" afterPath="$PROJECT_DIR$/examples/quotesToScrapeJs/parser_schema.py" afterDir="false" />
14
+ <change beforePath="$PROJECT_DIR$/pyproject.toml" beforeDir="false" afterPath="$PROJECT_DIR$/pyproject.toml" afterDir="false" />
15
+ <change beforePath="$PROJECT_DIR$/ssc_codegen/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssc_codegen/__init__.py" afterDir="false" />
9
16
  </list>
10
17
  <option name="SHOW_DIALOG" value="false" />
11
18
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -80,40 +87,41 @@
80
87
  <option name="hideEmptyMiddlePackages" value="true" />
81
88
  <option name="showLibraryContents" value="true" />
82
89
  </component>
83
- <component name="PropertiesComponent">{
84
- &quot;keyToString&quot;: {
85
- &quot;Dart Command Line App.main.dart.executor&quot;: &quot;Run&quot;,
86
- &quot;DefaultHtmlFileTemplate&quot;: &quot;HTML File&quot;,
87
- &quot;Python tests.pytest for test_json_converter.test_json_converter.executor&quot;: &quot;Run&quot;,
88
- &quot;Python.__init__.executor&quot;: &quot;Run&quot;,
89
- &quot;Python._o.executor&quot;: &quot;Debug&quot;,
90
- &quot;Python.base.executor&quot;: &quot;Run&quot;,
91
- &quot;Python.constants.executor&quot;: &quot;Run&quot;,
92
- &quot;Python.consts.executor&quot;: &quot;Run&quot;,
93
- &quot;Python.e.executor&quot;: &quot;Run&quot;,
94
- &quot;Python.json_struct.executor&quot;: &quot;Run&quot;,
95
- &quot;Python.json_to_schema.executor&quot;: &quot;Run&quot;,
96
- &quot;Python.main (1).executor&quot;: &quot;Run&quot;,
97
- &quot;Python.main.executor&quot;: &quot;Run&quot;,
98
- &quot;Python.py_parsel.executor&quot;: &quot;Run&quot;,
99
- &quot;Python.schema.executor&quot;: &quot;Run&quot;,
100
- &quot;Python.schemas.executor&quot;: &quot;Run&quot;,
101
- &quot;Python.template.executor&quot;: &quot;Run&quot;,
102
- &quot;Python.tokens.executor&quot;: &quot;Run&quot;,
103
- &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
104
- &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
105
- &quot;dart.analysis.tool.window.visible&quot;: &quot;false&quot;,
106
- &quot;git-widget-placeholder&quot;: &quot;main&quot;,
107
- &quot;last_opened_file_path&quot;: &quot;/home/georgiy/PycharmProjects/selector_schema_codegen&quot;,
108
- &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
109
- &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
110
- &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
111
- &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
112
- &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
113
- &quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
114
- &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
90
+ <component name="PropertiesComponent"><![CDATA[{
91
+ "keyToString": {
92
+ "Dart Command Line App.main.dart.executor": "Run",
93
+ "DefaultHtmlFileTemplate": "HTML File",
94
+ "Python tests.pytest for test_json_converter.test_json_converter.executor": "Run",
95
+ "Python.__init__.executor": "Run",
96
+ "Python._o.executor": "Debug",
97
+ "Python.base.executor": "Run",
98
+ "Python.constants.executor": "Run",
99
+ "Python.consts.executor": "Run",
100
+ "Python.e.executor": "Run",
101
+ "Python.json_struct.executor": "Run",
102
+ "Python.json_to_schema.executor": "Run",
103
+ "Python.main (1).executor": "Run",
104
+ "Python.main (2).executor": "Run",
105
+ "Python.main.executor": "Run",
106
+ "Python.py_parsel.executor": "Run",
107
+ "Python.schema.executor": "Run",
108
+ "Python.schemas.executor": "Run",
109
+ "Python.template.executor": "Run",
110
+ "Python.tokens.executor": "Run",
111
+ "RunOnceActivity.ShowReadmeOnStart": "true",
112
+ "RunOnceActivity.git.unshallow": "true",
113
+ "dart.analysis.tool.window.visible": "false",
114
+ "git-widget-placeholder": "main",
115
+ "last_opened_file_path": "/home/georgiy/PycharmProjects/selector_schema_codegen/ssc_codegen/utils",
116
+ "node.js.detected.package.eslint": "true",
117
+ "node.js.detected.package.tslint": "true",
118
+ "node.js.selected.package.eslint": "(autodetect)",
119
+ "node.js.selected.package.tslint": "(autodetect)",
120
+ "nodejs_package_manager_path": "npm",
121
+ "settings.editor.selected.configurable": "preferences.pluginManager",
122
+ "vue.rearranger.settings.migration": "true"
115
123
  }
116
- }</component>
124
+ }]]></component>
117
125
  <component name="RecentsManager">
118
126
  <key name="CopyFile.RECENT_KEYS">
119
127
  <recent name="$PROJECT_DIR$/test_dart" />
@@ -122,13 +130,14 @@
122
130
  <recent name="$PROJECT_DIR$/ssc_codegen2/converters/templates/py/bs4" />
123
131
  </key>
124
132
  <key name="MoveFile.RECENT_KEYS">
125
- <recent name="$PROJECT_DIR$/test_dart" />
126
- <recent name="$PROJECT_DIR$/example/py" />
127
- <recent name="$PROJECT_DIR$/ssc_codegen2/converters/templates/py" />
128
- <recent name="$PROJECT_DIR$/ssc_codegen2/converters" />
133
+ <recent name="$PROJECT_DIR$/ssc_codegen" />
134
+ <recent name="$PROJECT_DIR$/ssc_codegen/utils" />
135
+ <recent name="$PROJECT_DIR$/ssc_codegen/utils/tools.py" />
136
+ <recent name="$PROJECT_DIR$/ssc_codegen/utils/str_utils.py" />
137
+ <recent name="$PROJECT_DIR$/ssc_codegen/cli" />
129
138
  </key>
130
139
  </component>
131
- <component name="RunManager" selected="Python.main (1)">
140
+ <component name="RunManager" selected="Python.main (2)">
132
141
  <configuration name="_o" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
133
142
  <module name="selector_schema_codegen" />
134
143
  <option name="ENV_FILES" value="" />
@@ -152,7 +161,7 @@
152
161
  <option name="INPUT_FILE" value="" />
153
162
  <method v="2" />
154
163
  </configuration>
155
- <configuration name="json_to_schema" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
164
+ <configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
156
165
  <module name="selector_schema_codegen" />
157
166
  <option name="ENV_FILES" value="" />
158
167
  <option name="INTERPRETER_OPTIONS" value="" />
@@ -161,12 +170,12 @@
161
170
  <env name="PYTHONUNBUFFERED" value="1" />
162
171
  </envs>
163
172
  <option name="SDK_HOME" value="" />
164
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/ssc_codegen/converters" />
173
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/examples/quotesToScrapeJs" />
165
174
  <option name="IS_MODULE_SDK" value="true" />
166
175
  <option name="ADD_CONTENT_ROOTS" value="true" />
167
176
  <option name="ADD_SOURCE_ROOTS" value="true" />
168
177
  <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
169
- <option name="SCRIPT_NAME" value="$PROJECT_DIR$/ssc_codegen/converters/json_to_schema.py" />
178
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/examples/quotesToScrapeJs/main.py" />
170
179
  <option name="PARAMETERS" value="" />
171
180
  <option name="SHOW_COMMAND_LINE" value="false" />
172
181
  <option name="EMULATE_TERMINAL" value="false" />
@@ -175,7 +184,7 @@
175
184
  <option name="INPUT_FILE" value="" />
176
185
  <method v="2" />
177
186
  </configuration>
178
- <configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
187
+ <configuration name="main (2)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
179
188
  <module name="selector_schema_codegen" />
180
189
  <option name="ENV_FILES" value="" />
181
190
  <option name="INTERPRETER_OPTIONS" value="" />
@@ -184,12 +193,12 @@
184
193
  <env name="PYTHONUNBUFFERED" value="1" />
185
194
  </envs>
186
195
  <option name="SDK_HOME" value="" />
187
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/examples/quotesToScrapeJs" />
196
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/examples/booksToScrape/python" />
188
197
  <option name="IS_MODULE_SDK" value="true" />
189
198
  <option name="ADD_CONTENT_ROOTS" value="true" />
190
199
  <option name="ADD_SOURCE_ROOTS" value="true" />
191
200
  <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
192
- <option name="SCRIPT_NAME" value="$PROJECT_DIR$/examples/quotesToScrapeJs/main.py" />
201
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/examples/booksToScrape/python/main.py" />
193
202
  <option name="PARAMETERS" value="" />
194
203
  <option name="SHOW_COMMAND_LINE" value="false" />
195
204
  <option name="EMULATE_TERMINAL" value="false" />
@@ -241,11 +250,11 @@
241
250
  </configuration>
242
251
  <recent_temporary>
243
252
  <list>
253
+ <item itemvalue="Python.main (2)" />
244
254
  <item itemvalue="Python.main (1)" />
245
255
  <item itemvalue="Python._o" />
246
256
  <item itemvalue="Python tests.pytest for test_json_converter.test_json_converter" />
247
257
  <item itemvalue="Python.main" />
248
- <item itemvalue="Python.json_to_schema" />
249
258
  </list>
250
259
  </recent_temporary>
251
260
  </component>
@@ -295,7 +304,7 @@
295
304
  <workItem from="1739518425156" duration="136000" />
296
305
  <workItem from="1739518577894" duration="125000" />
297
306
  <workItem from="1739530470006" duration="12800000" />
298
- <workItem from="1739614174493" duration="887000" />
307
+ <workItem from="1739614174493" duration="13580000" />
299
308
  </task>
300
309
  <task id="LOCAL-00001" summary="first PoC">
301
310
  <option name="closed" value="true" />
@@ -617,7 +626,63 @@
617
626
  <option name="project" value="LOCAL" />
618
627
  <updated>1739569738536</updated>
619
628
  </task>
620
- <option name="localTasksCounter" value="41" />
629
+ <task id="LOCAL-00041" summary="refactoring codebase">
630
+ <option name="closed" value="true" />
631
+ <created>1739620462724</created>
632
+ <option name="number" value="00041" />
633
+ <option name="presentableId" value="LOCAL-00041" />
634
+ <option name="project" value="LOCAL" />
635
+ <updated>1739620462724</updated>
636
+ </task>
637
+ <task id="LOCAL-00042" summary="update imports">
638
+ <option name="closed" value="true" />
639
+ <created>1739620475383</created>
640
+ <option name="number" value="00042" />
641
+ <option name="presentableId" value="LOCAL-00042" />
642
+ <option name="project" value="LOCAL" />
643
+ <updated>1739620475383</updated>
644
+ </task>
645
+ <task id="LOCAL-00043" summary="add JSON_STRUCT, JSON_STRUCT_FIELD converters">
646
+ <option name="closed" value="true" />
647
+ <created>1739621470292</created>
648
+ <option name="number" value="00043" />
649
+ <option name="presentableId" value="LOCAL-00043" />
650
+ <option name="project" value="LOCAL" />
651
+ <updated>1739621470292</updated>
652
+ </task>
653
+ <task id="LOCAL-00044" summary="refactoring JSON_STRUCT, JSON_FIELD converters">
654
+ <option name="closed" value="true" />
655
+ <created>1739621509631</created>
656
+ <option name="number" value="00044" />
657
+ <option name="presentableId" value="LOCAL-00044" />
658
+ <option name="project" value="LOCAL" />
659
+ <updated>1739621509631</updated>
660
+ </task>
661
+ <task id="LOCAL-00045" summary="TypeDefField: add nested_node_ref property for find accociated StructParser node">
662
+ <option name="closed" value="true" />
663
+ <created>1739625538057</created>
664
+ <option name="number" value="00045" />
665
+ <option name="presentableId" value="LOCAL-00045" />
666
+ <option name="project" value="LOCAL" />
667
+ <updated>1739625538057</updated>
668
+ </task>
669
+ <task id="LOCAL-00046" summary="refactoring STRUCT_FIELD, TYPEDEF, TYPEDEF_FIELD">
670
+ <option name="closed" value="true" />
671
+ <created>1739625667076</created>
672
+ <option name="number" value="00046" />
673
+ <option name="presentableId" value="LOCAL-00046" />
674
+ <option name="project" value="LOCAL" />
675
+ <updated>1739625667076</updated>
676
+ </task>
677
+ <task id="LOCAL-00047" summary="refactoring TYPEDEF, TYPEDEF_FIELD,">
678
+ <option name="closed" value="true" />
679
+ <created>1739628163377</created>
680
+ <option name="number" value="00047" />
681
+ <option name="presentableId" value="LOCAL-00047" />
682
+ <option name="project" value="LOCAL" />
683
+ <updated>1739628163377</updated>
684
+ </task>
685
+ <option name="localTasksCounter" value="48" />
621
686
  <servers />
622
687
  </component>
623
688
  <component name="TypeScriptGeneratedFilesManager">
@@ -635,13 +700,6 @@
635
700
  </option>
636
701
  </component>
637
702
  <component name="VcsManagerConfiguration">
638
- <MESSAGE value="add new type: json&#10;&#10;ast: fix typedef parent node type" />
639
- <MESSAGE value="builder: add json nodes&#10;utils: add helper function search instance" />
640
- <MESSAGE value="jsonify operation" />
641
- <MESSAGE value="py_parsel: &#10; - StructFieldFunction: add JSON annotation&#10;&#10;py_base:&#10; - implement TO_JSON, JSON_STRUCT converters&#10; - typedef: add parse json types" />
642
- <MESSAGE value="typing extension if python&lt;3.11" />
643
- <MESSAGE value="schema parse json signature&#10;move Json shortcut to __init__.py" />
644
- <MESSAGE value="json extract and parse example" />
645
703
  <MESSAGE value="WIP: stub json nodes" />
646
704
  <MESSAGE value="add json converter to code config" />
647
705
  <MESSAGE value="py:&#10;fix typedef type JSON gen&#10;fix json struct list[Json] convert type&#10;bs4, scrapy, selectolax: &#10;fix JSON annotation gen&#10;fix typedef JSON type gen&#10;js: add TO_JSON&#10;go: add TO_JSON, JSON_STRUCT" />
@@ -660,20 +718,21 @@
660
718
  <MESSAGE value="extract json example (quotesToScrapeJs)" />
661
719
  <MESSAGE value="ruff fmt" />
662
720
  <MESSAGE value="generated code" />
663
- <option name="LAST_COMMIT_MESSAGE" value="generated code" />
721
+ <MESSAGE value="refactoring codebase" />
722
+ <MESSAGE value="update imports" />
723
+ <MESSAGE value="add JSON_STRUCT, JSON_STRUCT_FIELD converters" />
724
+ <MESSAGE value="refactoring JSON_STRUCT, JSON_FIELD converters" />
725
+ <MESSAGE value="TypeDefField: add nested_node_ref property for find accociated StructParser node" />
726
+ <MESSAGE value="refactoring STRUCT_FIELD, TYPEDEF, TYPEDEF_FIELD" />
727
+ <MESSAGE value="refactoring TYPEDEF, TYPEDEF_FIELD," />
728
+ <option name="LAST_COMMIT_MESSAGE" value="refactoring TYPEDEF, TYPEDEF_FIELD," />
664
729
  </component>
665
730
  <component name="XDebuggerManager">
666
731
  <breakpoint-manager>
667
732
  <breakpoints>
668
733
  <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
669
- <url>file://$PROJECT_DIR$/ssc_codegen/converters/py_base.py</url>
670
- <line>137</line>
671
- <option name="timeStamp" value="17" />
672
- </line-breakpoint>
673
- <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
674
- <url>file://$PROJECT_DIR$/ssc_codegen/converters/templates/go.py</url>
675
- <line>983</line>
676
- <option name="timeStamp" value="24" />
734
+ <url>file://$PROJECT_DIR$/ssc_codegen/cli/cli_utils.py</url>
735
+ <option name="timeStamp" value="25" />
677
736
  </line-breakpoint>
678
737
  </breakpoints>
679
738
  </breakpoint-manager>
@@ -685,6 +744,7 @@
685
744
  <SUITE FILE_PATH="coverage/selector_schema_codegen$json_struct.coverage" NAME="json_struct Coverage Results" MODIFIED="1739388527238" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen" />
686
745
  <SUITE FILE_PATH="coverage/selector_schema_codegen$schemas.coverage" NAME="schemas Coverage Results" MODIFIED="1715691155477" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2/schema" />
687
746
  <SUITE FILE_PATH="coverage/selector_schema_codegen$__init__.coverage" NAME="__init__ Coverage Results" MODIFIED="1715757563224" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2/document" />
747
+ <SUITE FILE_PATH="coverage/selector_schema_codegen$main__2_.coverage" NAME="main (2) Coverage Results" MODIFIED="1739625275679" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/examples/booksToScrape/python" />
688
748
  <SUITE FILE_PATH="coverage/selector_schema_codegen$_o.coverage" NAME="_o Coverage Results" MODIFIED="1739466687613" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/examples/tutorial/7_json_extract" />
689
749
  <SUITE FILE_PATH="coverage/selector_schema_codegen$json_to_schema.coverage" NAME="json_to_schema Coverage Results" MODIFIED="1739444979920" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen/converters" />
690
750
  <SUITE FILE_PATH="coverage/selector_schema_codegen$constants.coverage" NAME="constants Coverage Results" MODIFIED="1715927681292" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ssc_codegen2/schema" />
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ssc_codegen
3
- Version: 0.6.0
3
+ Version: 0.6.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
@@ -185,14 +185,14 @@ class Books {
185
185
 
186
186
  /// books.toscrape.com catalogue page entrypoint parser
187
187
  ///
188
- /// USAGE:
188
+ /// USAGE:
189
189
  ///
190
- /// 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
191
- /// 2. add another prepare instruction how to correct cook page (if needed?)
190
+ /// 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
191
+ /// 2. add another prepare instruction how to correct cook page (if needed?)
192
192
  ///
193
- /// ISSUES:
193
+ /// ISSUES:
194
194
  ///
195
- /// 1. nope! Their love being scraped!
195
+ /// 1. nope! Their love being scraped!
196
196
  ///
197
197
  ///
198
198
  /// {
@@ -211,7 +211,7 @@ class Books {
211
211
  /// "image_url": "String",
212
212
  /// "url": "String",
213
213
  /// "rating": "String",
214
- /// "price": "Any"
214
+ /// "price": "Int"
215
215
  /// },
216
216
  /// "..."
217
217
  /// ]
@@ -20,19 +20,20 @@ type TBooks struct {
20
20
  Rating string `json:"rating"`
21
21
  Price int `json:"price"`
22
22
  }
23
- type TBooksITEMS = []TBooks
24
23
  type TCataloguePage struct {
25
- Title string `json:"title"`
26
- Urls TUrls `json:"urls"`
27
- UrlsMap TUrlsMap `json:"urls_map"`
28
- Books TBooksITEMS `json:"books"`
24
+ Title string `json:"title"`
25
+ Urls TUrls `json:"urls"`
26
+ UrlsMap TUrlsMap `json:"urls_map"`
27
+ Books []TBooks `json:"books"`
29
28
  }
30
29
 
31
30
  // Urls fetch add patches and urls from <a> tag
32
31
  //
33
32
  // [
34
- // "String",
35
- // "..."
33
+ //
34
+ // "String",
35
+ // "..."
36
+ //
36
37
  // ]
37
38
  type Urls struct{ Document *goquery.Document }
38
39
 
@@ -65,10 +66,10 @@ func (p *Urls) Parse() (*TUrls, error) {
65
66
 
66
67
  // UrlsMap
67
68
  //
68
- // {
69
- // "<K>": "String",
70
- // "<KN>": "..."
71
- // }
69
+ // {
70
+ // "<K>": "String",
71
+ // "<KN>": "..."
72
+ // }
72
73
  type UrlsMap struct{ Document *goquery.Document }
73
74
 
74
75
  func (p *UrlsMap) splitDoc(value *goquery.Selection) (*goquery.Selection, error) {
@@ -113,14 +114,16 @@ func (p *UrlsMap) Parse() (*TUrlsMap, error) {
113
114
  // Books
114
115
  //
115
116
  // [
116
- // {
117
- // "name": "String",
118
- // "image_url": "String",
119
- // "url": "String",
120
- // "rating": "String",
121
- // "price": "Int"
122
- // },
123
- // "..."
117
+ //
118
+ // {
119
+ // "name": "String",
120
+ // "image_url": "String",
121
+ // "url": "String",
122
+ // "rating": "String",
123
+ // "price": "Int"
124
+ // },
125
+ // "..."
126
+ //
124
127
  // ]
125
128
  type Books struct{ Document *goquery.Document }
126
129
 
@@ -171,7 +174,7 @@ func (p *Books) parsePrice(value *goquery.Selection) (result int, err error) {
171
174
  value1 := value
172
175
  value2 := value1.Find(".price_color").First()
173
176
  value3 := value2.Text()
174
- value4 := regexp.MustCompile(`(\d+)`).FindStringSubmatch(value3)[0]
177
+ value4 := regexp.MustCompile(`(\d+)`).FindStringSubmatch(value3)[1]
175
178
  value5, err := strconv.Atoi(value4)
176
179
  if err != nil {
177
180
  panic(err)
@@ -179,8 +182,8 @@ func (p *Books) parsePrice(value *goquery.Selection) (result int, err error) {
179
182
  result = value5
180
183
  return result, nil
181
184
  }
182
- func (p *Books) Parse() (*TBooksITEMS, error) {
183
- items := make(TBooksITEMS, 0)
185
+ func (p *Books) Parse() (*[]TBooks, error) {
186
+ items := make([]TBooks, 0)
184
187
  docParts, err := p.splitDoc(p.Document.Selection)
185
188
  if err != nil {
186
189
  return nil, err
@@ -211,37 +214,36 @@ func (p *Books) Parse() (*TBooksITEMS, error) {
211
214
 
212
215
  // CataloguePage books.toscrape.com catalogue page entrypoint parser
213
216
  //
214
- // USAGE:
215
- //
216
- // 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
217
- // 2. add another prepare instruction how to correct cook page (if needed?)
217
+ // USAGE:
218
218
  //
219
- // ISSUES:
219
+ // 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
220
+ // 2. add another prepare instruction how to correct cook page (if needed?)
220
221
  //
221
- // 1. nope! Their love being scraped!
222
+ // ISSUES:
222
223
  //
224
+ // 1. nope! Their love being scraped!
223
225
  //
224
- // {
225
- // "title": "String",
226
- // "urls": [
227
- // "String",
228
- // "..."
229
- // ],
230
- // "urls_map": {
231
- // "<K>": "String",
232
- // "<KN>": "..."
233
- // },
234
- // "books": [
235
- // {
236
- // "name": "String",
237
- // "image_url": "String",
238
- // "url": "String",
239
- // "rating": "String",
240
- // "price": "Any"
241
- // },
242
- // "..."
243
- // ]
244
- // }
226
+ // {
227
+ // "title": "String",
228
+ // "urls": [
229
+ // "String",
230
+ // "..."
231
+ // ],
232
+ // "urls_map": {
233
+ // "<K>": "String",
234
+ // "<KN>": "..."
235
+ // },
236
+ // "books": [
237
+ // {
238
+ // "name": "String",
239
+ // "image_url": "String",
240
+ // "url": "String",
241
+ // "rating": "String",
242
+ // "price": "Int"
243
+ // },
244
+ // "..."
245
+ // ]
246
+ // }
245
247
  type CataloguePage struct{ Document *goquery.Document }
246
248
 
247
249
  func (p *CataloguePage) preValidate(value *goquery.Selection) (error, error) {
@@ -289,7 +291,7 @@ func (p *CataloguePage) parseUrlsMap(value *goquery.Selection) (TUrlsMap, error)
289
291
  }
290
292
  return *value1, nil
291
293
  }
292
- func (p *CataloguePage) parseBooks(value *goquery.Selection) (TBooksITEMS, error) {
294
+ func (p *CataloguePage) parseBooks(value *goquery.Selection) ([]TBooks, error) {
293
295
  doc0 := goquery.NewDocumentFromNode(value.Nodes[0])
294
296
  st0 := Books{doc0}
295
297
  value1, err := st0.Parse()
@@ -11,9 +11,9 @@
11
11
  * ]
12
12
  */
13
13
  class Urls{
14
- constructor(doc){this._doc = typeof document === 'string' ? new DOMParser().parseFromString(doc, 'text/html') : doc;}
14
+ constructor(doc){if (typeof doc === 'string') {this._doc = new DOMParser().parseFromString(doc, 'text/html');}else if (doc instanceof Document || doc instanceof Element){this._doc = doc;}else{ throw new Error("Invalid input: Expected a Document, Element, or string");}}
15
15
  _splitDoc(value){
16
- let value1 = value.querySelectorAll('a');
16
+ let value1 = Array.from(value.querySelectorAll('a'));
17
17
  return value1;
18
18
  }
19
19
  _parseItem(value){
@@ -32,9 +32,9 @@ let items = Array.from(this._splitDoc(this._doc)).map((e) => this._parseItem(e))
32
32
  * }
33
33
  */
34
34
  class UrlsMap{
35
- constructor(doc){this._doc = typeof document === 'string' ? new DOMParser().parseFromString(doc, 'text/html') : doc;}
35
+ constructor(doc){if (typeof doc === 'string') {this._doc = new DOMParser().parseFromString(doc, 'text/html');}else if (doc instanceof Document || doc instanceof Element){this._doc = doc;}else{ throw new Error("Invalid input: Expected a Document, Element, or string");}}
36
36
  _splitDoc(value){
37
- let value1 = value.querySelectorAll('a');
37
+ let value1 = Array.from(value.querySelectorAll('a'));
38
38
  return value1;
39
39
  }
40
40
  _parseKey(value){
@@ -42,7 +42,7 @@ let value1 = value.getAttribute('href');
42
42
  return value1;
43
43
  }
44
44
  _parseValue(value){
45
- let value1 = value.querySelector("html").innerHTML;
45
+ let value1 = typeof value.outerHTML === "undefined" ? value.documentElement.outerHTML : value.outerHTML;
46
46
  let value2 = (function (str, chars){return str.replace(new RegExp(`^[${chars}]+|[${chars}]+$`, 'g'), '');})(value1, ' ');
47
47
  return value2;
48
48
  }
@@ -64,9 +64,9 @@ let item = {};Array.from(this._splitDoc(this._doc)).forEach((e) =>{let k = this.
64
64
  * ]
65
65
  */
66
66
  class Books{
67
- constructor(doc){this._doc = typeof document === 'string' ? new DOMParser().parseFromString(doc, 'text/html') : doc;}
67
+ constructor(doc){if (typeof doc === 'string') {this._doc = new DOMParser().parseFromString(doc, 'text/html');}else if (doc instanceof Document || doc instanceof Element){this._doc = doc;}else{ throw new Error("Invalid input: Expected a Document, Element, or string");}}
68
68
  _splitDoc(value){
69
- let value1 = value.querySelectorAll('.col-lg-3');
69
+ let value1 = Array.from(value.querySelectorAll('.col-lg-3'));
70
70
  return value1;
71
71
  }
72
72
  _parseName(value){
@@ -94,8 +94,9 @@ return value3;
94
94
  _parsePrice(value){
95
95
  try {
96
96
  let value2 = value1.querySelector('.price_color');
97
- let value3 = value2.textContent;
98
- let value4 = value3.match(/(\d+)/g)[0];
97
+ let value3 = typeof value2.textContent === "undefined" ? value2.documentElement.textContent : value2.textContent;
98
+ let value4 = (new RegExp(/(\d+)/g)).exec(value3)[1];
99
+ let value5 = parseInt(value4, 10);
99
100
  return value6;
100
101
  } catch(Error) {return 0;}
101
102
  }
@@ -105,15 +106,15 @@ let items = [];Array.from(this._splitDoc(this._doc)).forEach((e) =>{items.push({
105
106
  /**
106
107
  * books.toscrape.com catalogue page entrypoint parser
107
108
  *
108
- * USAGE:
109
+ * USAGE:
109
110
  *
110
- * 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
111
- * 2. add another prepare instruction how to correct cook page (if needed?)
111
+ * 1. GET <catalog page> (https://books.toscrape.com/, https://books.toscrape.com/catalogue/page-2.html, ...)
112
+ * 2. add another prepare instruction how to correct cook page (if needed?)
112
113
  *
113
- * ISSUES:
114
+ * ISSUES:
115
+ *
116
+ * 1. nope! Their love being scraped!
114
117
  *
115
- * 1. nope! Their love being scraped!
116
- *
117
118
  *
118
119
  * {
119
120
  * "title": "String",
@@ -131,17 +132,17 @@ let items = [];Array.from(this._splitDoc(this._doc)).forEach((e) =>{items.push({
131
132
  * "image_url": "String",
132
133
  * "url": "String",
133
134
  * "rating": "String",
134
- * "price": "Any"
135
+ * "price": "Int"
135
136
  * },
136
137
  * "..."
137
138
  * ]
138
139
  * }
139
140
  */
140
141
  class CataloguePage{
141
- constructor(doc){this._doc = typeof document === 'string' ? new DOMParser().parseFromString(doc, 'text/html') : doc;}
142
+ constructor(doc){if (typeof doc === 'string') {this._doc = new DOMParser().parseFromString(doc, 'text/html');}else if (doc instanceof Document || doc instanceof Element){this._doc = doc;}else{ throw new Error("Invalid input: Expected a Document, Element, or string");}}
142
143
  _preValidate(value){
143
144
  let value1 = value.querySelector('title');
144
- let value2 = value1.textContent;
145
+ let value2 = typeof value1.textContent === "undefined" ? value1.documentElement.textContent : value1.textContent;
145
146
  if (value2.match(/Books to Scrape/) === null) throw new Error('');
146
147
  return null;
147
148
  }
@@ -149,7 +150,7 @@ _parseTitle(value){
149
150
  try {
150
151
  if (!value1.querySelector('title')) throw new Error('');let value2 = value1;
151
152
  let value3 = value2.querySelector('title');
152
- let value4 = value3.textContent;
153
+ let value4 = typeof value3.textContent === "undefined" ? value3.documentElement.textContent : value3.textContent;
153
154
  let value5 = value4.replace(/^\s+/g, '');
154
155
  let value6 = value5.replace(/\s+$/g, '');
155
156
  return value7;