zleap-parser 0.1.0__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 (102) hide show
  1. zleap_parser-0.1.0/.gitignore +63 -0
  2. zleap_parser-0.1.0/LICENSE +21 -0
  3. zleap_parser-0.1.0/LICENSES/Apache-2.0.txt +200 -0
  4. zleap_parser-0.1.0/PKG-INFO +131 -0
  5. zleap_parser-0.1.0/README.md +88 -0
  6. zleap_parser-0.1.0/THIRD_PARTY_NOTICES.md +27 -0
  7. zleap_parser-0.1.0/docs/README.md +28 -0
  8. zleap_parser-0.1.0/docs/sdk/configuration.md +114 -0
  9. zleap_parser-0.1.0/docs/sdk/connector_api.md +235 -0
  10. zleap_parser-0.1.0/docs/sdk/install.md +90 -0
  11. zleap_parser-0.1.0/docs/sdk/parse_api.md +175 -0
  12. zleap_parser-0.1.0/docs/service/api.md +102 -0
  13. zleap_parser-0.1.0/docs/service/deployment.md +138 -0
  14. zleap_parser-0.1.0/hatch_build.py +32 -0
  15. zleap_parser-0.1.0/pyproject.toml +107 -0
  16. zleap_parser-0.1.0/scripts/export_project_octx.py +106 -0
  17. zleap_parser-0.1.0/src/main.py +215 -0
  18. zleap_parser-0.1.0/src/zleap_parser/__init__.py +67 -0
  19. zleap_parser-0.1.0/src/zleap_parser/adapters/__init__.py +45 -0
  20. zleap_parser-0.1.0/src/zleap_parser/adapters/core/__init__.py +10 -0
  21. zleap_parser-0.1.0/src/zleap_parser/adapters/core/base.py +78 -0
  22. zleap_parser-0.1.0/src/zleap_parser/adapters/core/engine.py +168 -0
  23. zleap_parser-0.1.0/src/zleap_parser/adapters/core/mimetype.py +179 -0
  24. zleap_parser-0.1.0/src/zleap_parser/adapters/core/registry.py +72 -0
  25. zleap_parser-0.1.0/src/zleap_parser/adapters/docx_adapter.py +107 -0
  26. zleap_parser-0.1.0/src/zleap_parser/adapters/html_adapter.py +292 -0
  27. zleap_parser-0.1.0/src/zleap_parser/adapters/image_adapter.py +19 -0
  28. zleap_parser-0.1.0/src/zleap_parser/adapters/pdf_adapter.py +317 -0
  29. zleap_parser-0.1.0/src/zleap_parser/adapters/plain_adapter.py +20 -0
  30. zleap_parser-0.1.0/src/zleap_parser/adapters/url_adapter.py +169 -0
  31. zleap_parser-0.1.0/src/zleap_parser/adapters/utils/__init__.py +15 -0
  32. zleap_parser-0.1.0/src/zleap_parser/adapters/utils/docling.py +93 -0
  33. zleap_parser-0.1.0/src/zleap_parser/adapters/xml_adapter.py +60 -0
  34. zleap_parser-0.1.0/src/zleap_parser/cache/__init__.py +240 -0
  35. zleap_parser-0.1.0/src/zleap_parser/config.py +138 -0
  36. zleap_parser-0.1.0/src/zleap_parser/connector/__init__.py +97 -0
  37. zleap_parser-0.1.0/src/zleap_parser/connector/connector.py +431 -0
  38. zleap_parser-0.1.0/src/zleap_parser/connector/exceptions.py +23 -0
  39. zleap_parser-0.1.0/src/zleap_parser/connector/loader/__init__.py +193 -0
  40. zleap_parser-0.1.0/src/zleap_parser/connector/sources/__init__.py +58 -0
  41. zleap_parser-0.1.0/src/zleap_parser/connector/sources/api_request.py +209 -0
  42. zleap_parser-0.1.0/src/zleap_parser/connector/sources/builtin.py +38 -0
  43. zleap_parser-0.1.0/src/zleap_parser/connector/sources/core/__init__.py +41 -0
  44. zleap_parser-0.1.0/src/zleap_parser/connector/sources/core/base.py +138 -0
  45. zleap_parser-0.1.0/src/zleap_parser/connector/sources/core/chat.py +98 -0
  46. zleap_parser-0.1.0/src/zleap_parser/connector/sources/core/registry.py +79 -0
  47. zleap_parser-0.1.0/src/zleap_parser/connector/sources/feishu_bot.py +498 -0
  48. zleap_parser-0.1.0/src/zleap_parser/connector/sources/git_repository.py +1564 -0
  49. zleap_parser-0.1.0/src/zleap_parser/connector/sources/rss.py +216 -0
  50. zleap_parser-0.1.0/src/zleap_parser/connector/sources/salesmartly_chat.py +506 -0
  51. zleap_parser-0.1.0/src/zleap_parser/connector/sources/wxwork.py +574 -0
  52. zleap_parser-0.1.0/src/zleap_parser/connector/sources/wxwork_sdk/WeWorkFinanceSdk_C.h +152 -0
  53. zleap_parser-0.1.0/src/zleap_parser/connector/sources/wxwork_sdk/libWeWorkFinanceSdk_C.so +0 -0
  54. zleap_parser-0.1.0/src/zleap_parser/downloader/__init__.py +309 -0
  55. zleap_parser-0.1.0/src/zleap_parser/downloader/attachments.py +98 -0
  56. zleap_parser-0.1.0/src/zleap_parser/downloader/http_client.py +183 -0
  57. zleap_parser-0.1.0/src/zleap_parser/exceptions.py +48 -0
  58. zleap_parser-0.1.0/src/zleap_parser/extract/__init__.py +8 -0
  59. zleap_parser-0.1.0/src/zleap_parser/extract/octx_export.py +447 -0
  60. zleap_parser-0.1.0/src/zleap_parser/extract/sag.py +539 -0
  61. zleap_parser-0.1.0/src/zleap_parser/parser.py +365 -0
  62. zleap_parser-0.1.0/src/zleap_parser/py.typed +0 -0
  63. zleap_parser-0.1.0/src/zleap_parser/url_collector/__init__.py +28 -0
  64. zleap_parser-0.1.0/src/zleap_parser/url_collector/browser.py +422 -0
  65. zleap_parser-0.1.0/src/zleap_parser/url_collector/collector.py +90 -0
  66. zleap_parser-0.1.0/src/zleap_parser/url_collector/extractor.py +174 -0
  67. zleap_parser-0.1.0/src/zleap_parser/url_collector/images.py +134 -0
  68. zleap_parser-0.1.0/src/zleap_parser/url_collector/markdown.py +372 -0
  69. zleap_parser-0.1.0/src/zleap_parser/url_collector/models.py +114 -0
  70. zleap_parser-0.1.0/src/zleap_parser/url_collector/resource_cache.py +78 -0
  71. zleap_parser-0.1.0/src/zleap_parser/url_collector/security.py +216 -0
  72. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/__init__.py +1 -0
  73. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/article_extractor.py +2024 -0
  74. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/http_client.py +35 -0
  75. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/models.py +404 -0
  76. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/proxy.py +66 -0
  77. zleap_parser-0.1.0/src/zleap_parser/url_collector/webcrawler/resource_cache.py +129 -0
  78. zleap_parser-0.1.0/src/zleap_parser/usage.py +169 -0
  79. zleap_parser-0.1.0/src/zleap_parser/utils.py +190 -0
  80. zleap_parser-0.1.0/tests/conftest.py +76 -0
  81. zleap_parser-0.1.0/tests/fixtures/rss_sample.xml +34 -0
  82. zleap_parser-0.1.0/tests/fixtures/sample.html +112 -0
  83. zleap_parser-0.1.0/tests/fixtures/sample.pdf +0 -0
  84. zleap_parser-0.1.0/tests/fixtures/sample.png +0 -0
  85. zleap_parser-0.1.0/tests/fixtures/sample.txt +182 -0
  86. zleap_parser-0.1.0/tests/fixtures/sample.xml +112 -0
  87. zleap_parser-0.1.0/tests/test_adapters.py +252 -0
  88. zleap_parser-0.1.0/tests/test_api_request.py +153 -0
  89. zleap_parser-0.1.0/tests/test_cache.py +139 -0
  90. zleap_parser-0.1.0/tests/test_config.py +130 -0
  91. zleap_parser-0.1.0/tests/test_connector.py +1103 -0
  92. zleap_parser-0.1.0/tests/test_feishu_bot.py +183 -0
  93. zleap_parser-0.1.0/tests/test_git_repository.py +561 -0
  94. zleap_parser-0.1.0/tests/test_http_client.py +90 -0
  95. zleap_parser-0.1.0/tests/test_main.py +196 -0
  96. zleap_parser-0.1.0/tests/test_mimetype_adapters.py +342 -0
  97. zleap_parser-0.1.0/tests/test_parser.py +605 -0
  98. zleap_parser-0.1.0/tests/test_robustness.py +211 -0
  99. zleap_parser-0.1.0/tests/test_sag_extract.py +154 -0
  100. zleap_parser-0.1.0/tests/test_salesmartly.py +187 -0
  101. zleap_parser-0.1.0/tests/test_url_collector.py +576 -0
  102. zleap_parser-0.1.0/tests/test_usage.py +216 -0
@@ -0,0 +1,63 @@
1
+ # ===== Python =====
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg-info/
7
+ .eggs/
8
+ build/
9
+ dist/
10
+ develop-eggs/
11
+ downloads/
12
+ eggs/
13
+ parts/
14
+ sdist/
15
+ var/
16
+ wheels/
17
+ .installed.cfg
18
+ *.egg
19
+ MANIFEST
20
+
21
+ # ===== 虚拟环境 =====
22
+ .venv/
23
+ venv/
24
+ env/
25
+ ENV/
26
+
27
+ # ===== 测试 / 静态检查 =====
28
+ .pytest_cache/
29
+ .mypy_cache/
30
+ .ruff_cache/
31
+ .tox/
32
+ nox/
33
+ .coverage
34
+ .coverage.*
35
+ htmlcov/
36
+ coverage.xml
37
+ *.cover
38
+
39
+ # ===== 缓存与产物 =====
40
+ *.octx
41
+ .octx-workspace/
42
+ tasks/
43
+
44
+ # ===== 环境变量 / 密钥 =====
45
+ .env
46
+ .env.*
47
+ !.env.example
48
+
49
+ # ===== 本地配置文件(含密钥,不入库)=====
50
+ config.local.toml
51
+ *.local.toml
52
+
53
+ # ===== 企业微信会话内容存档 C SDK(随包分发,需入库)=====
54
+ !src/zleap_parser/connector/sources/wxwork_sdk/
55
+ !src/zleap_parser/connector/sources/wxwork_sdk/*.so
56
+
57
+ # ===== IDE / 编辑器 / 系统 =====
58
+ .idea/
59
+ .vscode/
60
+ *.swp
61
+ *.swo
62
+ .DS_Store
63
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zleap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,200 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+ Copyright 2024 Alibaba Cloud
190
+ Copyright 2025 OpenDatalab Shanghai AILab
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198
+ See the License for the specific language governing permissions and
199
+ limitations under the License.
200
+
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.5
2
+ Name: zleap_parser
3
+ Version: 0.1.0
4
+ Summary: zleap 文档解析 SDK:多格式文件/URL 解析为 markdown,经 zleap-sag 提取、octx 打包为 *.octx 归档
5
+ Author: zleap
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ License-File: LICENSES/Apache-2.0.txt
9
+ Keywords: document,markdown,octx,parser,sag
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Text Processing :: Markup
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: beautifulsoup4>=4.14.3
19
+ Requires-Dist: cloakbrowser<0.4,>=0.3.26
20
+ Requires-Dist: octx>=0.1.3
21
+ Requires-Dist: pycryptodome>=3.19
22
+ Requires-Dist: pydantic<3,>=2
23
+ Requires-Dist: uuid6>=2024.7.10
24
+ Requires-Dist: zleap-sag>=0.7.1
25
+ Provides-Extra: dev
26
+ Requires-Dist: build>=1.2; extra == 'dev'
27
+ Requires-Dist: mypy>=1.10; extra == 'dev'
28
+ Requires-Dist: pytest-mock>=3.14; extra == 'dev'
29
+ Requires-Dist: pytest>=8.2; extra == 'dev'
30
+ Requires-Dist: ruff>=0.5; extra == 'dev'
31
+ Requires-Dist: twine>=5.0; extra == 'dev'
32
+ Provides-Extra: docx
33
+ Requires-Dist: docling>=2.0; extra == 'docx'
34
+ Requires-Dist: markitdown[docx]>=0.1.7; extra == 'docx'
35
+ Provides-Extra: pdf
36
+ Requires-Dist: docling>=2.0; extra == 'pdf'
37
+ Requires-Dist: markitdown[pdf]>=0.1.7; extra == 'pdf'
38
+ Requires-Dist: pypdfium2>=4.30; extra == 'pdf'
39
+ Requires-Dist: rapidocr>=3.3; extra == 'pdf'
40
+ Provides-Extra: redis
41
+ Requires-Dist: redis>=5.0; extra == 'redis'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # zleap_parser
45
+
46
+ `zleap_parser` 是 zleap 公司开源的**文档解析 SDK**:把本地文件或远程 HTML URL 解析为 markdown,经 `sag` 提取结构化产物后由 `octx` 打包为可传播的 `.octx` Package,供下游项目以 pip 方式集成使用。
47
+
48
+ > **当前状态:M1 基础框架已实施(开发中)。** 源码位于 `src/`(src 布局):`Parser`(`parse` / `markdown_to_octx` / 自定义适配器注册)、同步浏览器 URL 采集器、六类内置适配器(plain / image / pdf / docx / html / xml,插件化接入)、`zleap-sag` 提取封装与 `octx` 打包封装、旧文件下载器 SSRF 防护与本地二级缓存。计划文档见 `plan/`。
49
+
50
+ ## 阅读顺序
51
+
52
+ 1. **计划总览**([`plan/PLAN.md`](./plan/PLAN.md)):项目定位、里程碑划分(M1 解析器 / M2 连接器 / M3 公共服务)与门禁
53
+ 2. **SDK 导入手册**([`docs/sdk/install.md`](./docs/sdk/install.md)):环境要求、安装、快速上手
54
+ 3. **配置手册**([`docs/sdk/configuration.md`](./docs/sdk/configuration.md)):模块级一次配置,M1/M2 复用
55
+ 4. **文档解析 API 手册**([`docs/sdk/parse_api.md`](./docs/sdk/parse_api.md)):`Parser` 用法与异常表
56
+ 5. **连接器 API 手册**([`docs/sdk/connector_api.md`](./docs/sdk/connector_api.md)):数据源同步
57
+ 6. **公共服务手册**([`docs/service/`](./docs/service/)):部署与 HTTP API
58
+
59
+ ## 快速上手
60
+
61
+ 需要 Python 3.11 或更高版本:
62
+
63
+ ```bash
64
+ # 安装 Python 依赖
65
+ pip install -r requirements.txt # 上游依赖(octx / zleap-sag / uuid6 / pycryptodome + 开发工具链)
66
+ pip install -e . # 或 python -m pip install zleap_parser
67
+
68
+ # URL 采集首次运行前安装并检查 CloakBrowser 浏览器二进制
69
+ python -m cloakbrowser install
70
+ python -m cloakbrowser info
71
+ ```
72
+
73
+ 模块级配置一次(`llm` 与 `embedding` 必填),`Parser` 与 `Connector` 自动继承复用:
74
+
75
+ ```python
76
+ import zleap_parser
77
+ from zleap_parser import Parser, LLMConfig, EmbeddingConfig
78
+
79
+ zleap_parser.config(
80
+ llm=LLMConfig(base_url="https://api.xxx.com/v1", api_key="sk-...", model="qwen3.6-flash"),
81
+ embedding=EmbeddingConfig(model="Qwen/Qwen3-Embedding-0.6B", dimensions=1024),
82
+ )
83
+
84
+ parser = Parser()
85
+
86
+ # 本地文件走 magic bytes、格式适配器和文件内容缓存链路
87
+ result = parser.parse(file="/path/to/document.pdf")
88
+
89
+ # URL 只支持 HTML,走同步 CloakBrowser 正文采集链路
90
+ url_result = parser.parse(url="https://example.com/article")
91
+
92
+ # 两种入口都返回 {result: *.octx 归档文件路径, usage: LLM token 用量}
93
+ print(result["result"], result["usage"]) # usage: prompt_tokens / completion_tokens / total_tokens
94
+ print(url_result["result"], url_result["usage"])
95
+ ```
96
+
97
+ 本地冒烟测试(读取根目录 `.env` 初始化配置):
98
+
99
+ ```bash
100
+ cp .env.example .env # 填入 LLM / Embedding 配置
101
+ python src/main.py --list # 打印生效配置
102
+ python src/main.py tests/fixtures/sample.txt # 解析本地文件
103
+ python src/main.py # 默认解析 tests/fixtures/ 下全部样例
104
+ ```
105
+
106
+ ## 核心能力
107
+
108
+ | 能力 | 说明 | 手册 |
109
+ | --- | --- | --- |
110
+ | 文档解析(M1) | HTML URL / 本地文件 → markdown → `*.octx`;URL 正文规则与本地格式适配器分流 | [`parse_api.md`](./docs/sdk/parse_api.md) |
111
+ | 数据同步(M2) | 数据源(网页搜索等)文档清单 → 逐文档解析 → `*.octx` | [`connector_api.md`](./docs/sdk/connector_api.md) |
112
+ | 公共服务(M3) | 文档解析、连接器同步 HTTP API | [`service/`](./docs/service/) |
113
+
114
+ ## 要点
115
+
116
+ - 产出物统一为 `*.octx` 归档文件:可读 markdown + 稳定身份、版本、完整性信息及可选的 chunks、events、entities、vectors。
117
+ - 文件类型以 **magic bytes** 判定,不依赖扩展名。
118
+ - **配置**:模块级 `zleap_parser.config(...)` 一次配置,`Parser`/`Connector` 自动继承;实例级 `*.config()` 与全局合并,便于高度自定义。
119
+ - **缓存**:本地文件解析使用 Redis 或本地二级缓存;URL 输入每次重新执行浏览器采集,不使用持久缓存。
120
+ - **URL 采集**:只校验 HTTP(S) URL 格式,不执行 DNS/IP 类型判定;每次调用独立创建并关闭 Browser、Context、Page,不使用进程级信号量,多个线程可并发调用。正文提取、正文图片筛选和 Markdown 转换沿用参考 webcrawler 的规则语义,正文质量不足严格抛 `ConversionError`。
121
+ - **URL 附件**:成功渲染的 `page.html` 与成功下载的正文图片随 `markdown_to_octx(source_files=[...])` 以同一 `document_id` 写入 OCTX;远程 PDF/图片/普通文件不接受。
122
+ - **pdf 兜底链路**:用户自定义适配器 → Docling → markitdown(其他兜底可追加)。
123
+ - **docx 兜底链路**:用户自定义适配器 → Docling → markitdown;DOCX 内嵌图片随原文件写入 OCTX 附件。
124
+ - **异常**:所有 API 失败均抛 `ZleapParserError` 及子类(`ConfigError` / `AdapterNotFoundError` / `ConversionError` / `DownloadError` / `TimeoutError` / `ExtractError`),不裸奔底层异常;URL 采集编排层保留已有 SDK 异常,并将其他内部异常包装为 `ConversionError`。
125
+
126
+ ## 边界
127
+
128
+ - 不定义搜索 API、召回算法或 Agent 协议;解析与归档之外的能力由下游自行实现。
129
+ - 核心解析框架与格式实现解耦:新增格式即新增适配器,不改核心代码。
130
+ - 上游参考实现:`sag`(markdown 结构化提取)与 `octx`(`*.octx` 打包)位于本地仓库 `../SAG` 与 `../open-context`。
131
+ - URL 正文规则直接复制 MinerU HTML webcrawler 的正文抽取器(本地命名为 `article_extractor.py`);许可与归属见 [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 及 `LICENSES/`。
@@ -0,0 +1,88 @@
1
+ # zleap_parser
2
+
3
+ `zleap_parser` 是 zleap 公司开源的**文档解析 SDK**:把本地文件或远程 HTML URL 解析为 markdown,经 `sag` 提取结构化产物后由 `octx` 打包为可传播的 `.octx` Package,供下游项目以 pip 方式集成使用。
4
+
5
+ > **当前状态:M1 基础框架已实施(开发中)。** 源码位于 `src/`(src 布局):`Parser`(`parse` / `markdown_to_octx` / 自定义适配器注册)、同步浏览器 URL 采集器、六类内置适配器(plain / image / pdf / docx / html / xml,插件化接入)、`zleap-sag` 提取封装与 `octx` 打包封装、旧文件下载器 SSRF 防护与本地二级缓存。计划文档见 `plan/`。
6
+
7
+ ## 阅读顺序
8
+
9
+ 1. **计划总览**([`plan/PLAN.md`](./plan/PLAN.md)):项目定位、里程碑划分(M1 解析器 / M2 连接器 / M3 公共服务)与门禁
10
+ 2. **SDK 导入手册**([`docs/sdk/install.md`](./docs/sdk/install.md)):环境要求、安装、快速上手
11
+ 3. **配置手册**([`docs/sdk/configuration.md`](./docs/sdk/configuration.md)):模块级一次配置,M1/M2 复用
12
+ 4. **文档解析 API 手册**([`docs/sdk/parse_api.md`](./docs/sdk/parse_api.md)):`Parser` 用法与异常表
13
+ 5. **连接器 API 手册**([`docs/sdk/connector_api.md`](./docs/sdk/connector_api.md)):数据源同步
14
+ 6. **公共服务手册**([`docs/service/`](./docs/service/)):部署与 HTTP API
15
+
16
+ ## 快速上手
17
+
18
+ 需要 Python 3.11 或更高版本:
19
+
20
+ ```bash
21
+ # 安装 Python 依赖
22
+ pip install -r requirements.txt # 上游依赖(octx / zleap-sag / uuid6 / pycryptodome + 开发工具链)
23
+ pip install -e . # 或 python -m pip install zleap_parser
24
+
25
+ # URL 采集首次运行前安装并检查 CloakBrowser 浏览器二进制
26
+ python -m cloakbrowser install
27
+ python -m cloakbrowser info
28
+ ```
29
+
30
+ 模块级配置一次(`llm` 与 `embedding` 必填),`Parser` 与 `Connector` 自动继承复用:
31
+
32
+ ```python
33
+ import zleap_parser
34
+ from zleap_parser import Parser, LLMConfig, EmbeddingConfig
35
+
36
+ zleap_parser.config(
37
+ llm=LLMConfig(base_url="https://api.xxx.com/v1", api_key="sk-...", model="qwen3.6-flash"),
38
+ embedding=EmbeddingConfig(model="Qwen/Qwen3-Embedding-0.6B", dimensions=1024),
39
+ )
40
+
41
+ parser = Parser()
42
+
43
+ # 本地文件走 magic bytes、格式适配器和文件内容缓存链路
44
+ result = parser.parse(file="/path/to/document.pdf")
45
+
46
+ # URL 只支持 HTML,走同步 CloakBrowser 正文采集链路
47
+ url_result = parser.parse(url="https://example.com/article")
48
+
49
+ # 两种入口都返回 {result: *.octx 归档文件路径, usage: LLM token 用量}
50
+ print(result["result"], result["usage"]) # usage: prompt_tokens / completion_tokens / total_tokens
51
+ print(url_result["result"], url_result["usage"])
52
+ ```
53
+
54
+ 本地冒烟测试(读取根目录 `.env` 初始化配置):
55
+
56
+ ```bash
57
+ cp .env.example .env # 填入 LLM / Embedding 配置
58
+ python src/main.py --list # 打印生效配置
59
+ python src/main.py tests/fixtures/sample.txt # 解析本地文件
60
+ python src/main.py # 默认解析 tests/fixtures/ 下全部样例
61
+ ```
62
+
63
+ ## 核心能力
64
+
65
+ | 能力 | 说明 | 手册 |
66
+ | --- | --- | --- |
67
+ | 文档解析(M1) | HTML URL / 本地文件 → markdown → `*.octx`;URL 正文规则与本地格式适配器分流 | [`parse_api.md`](./docs/sdk/parse_api.md) |
68
+ | 数据同步(M2) | 数据源(网页搜索等)文档清单 → 逐文档解析 → `*.octx` | [`connector_api.md`](./docs/sdk/connector_api.md) |
69
+ | 公共服务(M3) | 文档解析、连接器同步 HTTP API | [`service/`](./docs/service/) |
70
+
71
+ ## 要点
72
+
73
+ - 产出物统一为 `*.octx` 归档文件:可读 markdown + 稳定身份、版本、完整性信息及可选的 chunks、events、entities、vectors。
74
+ - 文件类型以 **magic bytes** 判定,不依赖扩展名。
75
+ - **配置**:模块级 `zleap_parser.config(...)` 一次配置,`Parser`/`Connector` 自动继承;实例级 `*.config()` 与全局合并,便于高度自定义。
76
+ - **缓存**:本地文件解析使用 Redis 或本地二级缓存;URL 输入每次重新执行浏览器采集,不使用持久缓存。
77
+ - **URL 采集**:只校验 HTTP(S) URL 格式,不执行 DNS/IP 类型判定;每次调用独立创建并关闭 Browser、Context、Page,不使用进程级信号量,多个线程可并发调用。正文提取、正文图片筛选和 Markdown 转换沿用参考 webcrawler 的规则语义,正文质量不足严格抛 `ConversionError`。
78
+ - **URL 附件**:成功渲染的 `page.html` 与成功下载的正文图片随 `markdown_to_octx(source_files=[...])` 以同一 `document_id` 写入 OCTX;远程 PDF/图片/普通文件不接受。
79
+ - **pdf 兜底链路**:用户自定义适配器 → Docling → markitdown(其他兜底可追加)。
80
+ - **docx 兜底链路**:用户自定义适配器 → Docling → markitdown;DOCX 内嵌图片随原文件写入 OCTX 附件。
81
+ - **异常**:所有 API 失败均抛 `ZleapParserError` 及子类(`ConfigError` / `AdapterNotFoundError` / `ConversionError` / `DownloadError` / `TimeoutError` / `ExtractError`),不裸奔底层异常;URL 采集编排层保留已有 SDK 异常,并将其他内部异常包装为 `ConversionError`。
82
+
83
+ ## 边界
84
+
85
+ - 不定义搜索 API、召回算法或 Agent 协议;解析与归档之外的能力由下游自行实现。
86
+ - 核心解析框架与格式实现解耦:新增格式即新增适配器,不改核心代码。
87
+ - 上游参考实现:`sag`(markdown 结构化提取)与 `octx`(`*.octx` 打包)位于本地仓库 `../SAG` 与 `../open-context`。
88
+ - URL 正文规则直接复制 MinerU HTML webcrawler 的正文抽取器(本地命名为 `article_extractor.py`);许可与归属见 [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 及 `LICENSES/`。
@@ -0,0 +1,27 @@
1
+ # Third-Party Notices
2
+
3
+ ## MinerU HTML webcrawler rules
4
+
5
+ URL 正文提取、正文图片筛选和 Markdown 渲染的部分实现位于:
6
+
7
+ - `src/zleap_parser/url_collector/webcrawler/article_extractor.py`(参考原 `htmlx.py` 逐字节复制后改名)
8
+ - `src/zleap_parser/url_collector/webcrawler/models.py`
9
+ - `src/zleap_parser/url_collector/webcrawler/http_client.py`(同步入口保留参考异步签名,依赖延迟导入)
10
+ - `src/zleap_parser/url_collector/webcrawler/proxy.py`
11
+ - `src/zleap_parser/url_collector/webcrawler/resource_cache.py`
12
+ - `src/zleap_parser/url_collector/markdown.py`
13
+ - `src/zleap_parser/url_collector/resource_cache.py`
14
+
15
+ `article_extractor.py`(原 `htmlx.py`)副本 SHA-256:
16
+ `3b54647de752f05d28c65bc2229b3a85f6d09583237188977c4f61d6608ceeaf`
17
+
18
+ 这些实现派生自用户提供的 `mineru-html-feat-crawl-0714` 中
19
+ `dripper/crawl/vendors/webcrawler` 代码,原项目采用 Apache License 2.0。
20
+ Apache License 2.0 全文随本项目发布于 `LICENSES/Apache-2.0.txt`。
21
+
22
+ 原项目 NOTICE:
23
+
24
+ > This project contains code and model weights derived from Qwen3.
25
+ > Original Qwen3 Copyright 2024 Alibaba Cloud, licensed under Apache License 2.0.
26
+ > Modifications and additional training Copyright 2025 OpenDatalab Shanghai AILab,
27
+ > licensed under Apache License 2.0.
@@ -0,0 +1,28 @@
1
+ # zleap_parser 用户手册
2
+
3
+ > 本文档集面向下游用户与部署运维方。**M1(解析器 SDK)与 M2(连接器)已实施**,SDK 手册随实现同步修订;**M3(公共服务)待规划**,对应手册仍基于计划文档(`plan/`)编写,实现后随代码修订。
4
+
5
+ ## 手册索引
6
+
7
+ ### SDK 手册(M1 + M2,面向 SDK 使用者)
8
+
9
+ | 手册 | 内容 |
10
+ | --- | --- |
11
+ | [SDK 导入手册](./sdk/install.md) | 环境要求、安装、导入、快速上手 |
12
+ | [配置手册](./sdk/configuration.md) | 模块级/实例级配置、配置项字段、合并规则、缓存策略 |
13
+ | [文档解析 API 手册](./sdk/parse_api.md) | `Parser`:URL/文件 → `*.octx`、异常表 |
14
+ | [连接器数据同步 API 手册](./sdk/connector_api.md) | `Connector`:数据源同步 → `*.octx` 路径列表(单次可加载多文件)、可用性检查 |
15
+
16
+ ### 公共服务手册(M3,面向部署运维与调用方)
17
+
18
+ | 手册 | 内容 |
19
+ | --- | --- |
20
+ | [公共服务部署手册](./service/deployment.md) | 服务构建部署、config.toml 全字段与环境变量、探针、运维 |
21
+ | [公共服务 API 手册](./service/api.md) | HTTP API:鉴权、端点、任务状态机、错误码 |
22
+
23
+ ## 概念速览
24
+
25
+ - **格式适配器**(`zleap_parser.adapters`):把文件格式转 markdown 的插件(M1),类 `BaseAdapter`/`AdapterRegistry`。
26
+ - **数据源**(`zleap_parser.connector.sources`):获取文档清单的插件(M2),类 `DataSourceAdapter`/`SourceRegistry`。
27
+ - **`*.octx`**:解析产物归档文件,SDK 与公共服务所有 API 的最终产出物。
28
+ - **兜底链路**:pdf 转换(用户自定义适配器 → Docling → markitdown)、缓存(Redis → 本地二级)等优先路径失败时自动降级。