funapi-sciencedb 1.0.1__tar.gz → 1.1.2__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.
- funapi_sciencedb-1.1.2/.github/FUNDING.yml +1 -0
- funapi_sciencedb-1.1.2/.gitignore +195 -0
- funapi_sciencedb-1.1.2/CHANGELOG.md +100 -0
- funapi_sciencedb-1.1.2/PKG-INFO +70 -0
- funapi_sciencedb-1.1.2/README.md +57 -0
- funapi_sciencedb-1.1.2/conftest.py +11 -0
- funapi_sciencedb-1.1.2/generate.py +98 -0
- funapi_sciencedb-1.1.2/localize.py +420 -0
- funapi_sciencedb-1.1.2/openapi-ori.json +982 -0
- funapi_sciencedb-1.1.2/openapi-v3.json +1007 -0
- funapi_sciencedb-1.1.2/pyproject.toml +30 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/__init__.py +1 -1
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/__init__.py +1 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/open_api_controller/harvest_using_get.py +211 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/open_api_controller/json_using_get.py +164 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/api/open_api_controller/metrics_using_get.py +41 -41
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/open_api_controller/search_using_get.py +196 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/sushi_controller/get_api_status.py +171 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/sushi_controller/get_report_by_id_using_get.py +171 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/api/sushi_controller/get_reports.py +181 -0
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/client.py +274 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/errors.py +2 -2
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/__init__.py +3 -3
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/api_result_metrics_result.py +44 -17
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/api_result_search_result.py +44 -17
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_attributes.py +38 -12
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_contributors.py +38 -11
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_dates.py +36 -9
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_identifiers.py +36 -9
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_instance.py +43 -18
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_performance.py +36 -9
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_period.py +40 -13
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_report.py +44 -19
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_usage.py +59 -35
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_publisher_identifiers.py +38 -11
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/metrics_result.py +46 -19
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/search_record.py +60 -33
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/search_result.py +47 -20
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_error_model.py +42 -15
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_page_meta.py +41 -14
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report.py +37 -11
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report_header.py +54 -33
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report_header_report_attributes_item.py +34 -7
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report_header_report_filters_item.py +34 -7
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report_list.py +40 -14
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_report_page.py +41 -14
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_service_status.py +44 -19
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_service_status_alerts_item.py +34 -7
- funapi_sciencedb-1.1.2/src/funapi_sciencedb/py.typed +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/types.py +10 -12
- funapi_sciencedb-1.1.2/src/sciencedb/__init__.py +21 -0
- funapi_sciencedb-1.1.2/src/sciencedb/py.typed +0 -0
- funapi_sciencedb-1.1.2/tests/test_localize.py +240 -0
- funapi_sciencedb-1.1.2/tests/test_smoke.py +416 -0
- funapi_sciencedb-1.0.1/PKG-INFO +0 -10
- funapi_sciencedb-1.0.1/README.md +0 -1
- funapi_sciencedb-1.0.1/pyproject.toml +0 -7
- funapi_sciencedb-1.0.1/setup.cfg +0 -4
- funapi_sciencedb-1.0.1/src/funapi_sciencedb.egg-info/PKG-INFO +0 -10
- funapi_sciencedb-1.0.1/src/funapi_sciencedb.egg-info/SOURCES.txt +0 -57
- funapi_sciencedb-1.0.1/src/funapi_sciencedb.egg-info/dependency_links.txt +0 -1
- funapi_sciencedb-1.0.1/src/funapi_sciencedb.egg-info/requires.txt +0 -1
- funapi_sciencedb-1.0.1/src/funapi_sciencedb.egg-info/top_level.txt +0 -1
- funapi_sciencedb-1.0.1/src/sciencedb/api/__init__.py +0 -1
- funapi_sciencedb-1.0.1/src/sciencedb/api/open_api_controller/harvest_using_get.py +0 -211
- funapi_sciencedb-1.0.1/src/sciencedb/api/open_api_controller/json_using_get.py +0 -164
- funapi_sciencedb-1.0.1/src/sciencedb/api/open_api_controller/search_using_get.py +0 -196
- funapi_sciencedb-1.0.1/src/sciencedb/api/sushi_controller/get_api_status.py +0 -171
- funapi_sciencedb-1.0.1/src/sciencedb/api/sushi_controller/get_report_by_id_using_get.py +0 -173
- funapi_sciencedb-1.0.1/src/sciencedb/api/sushi_controller/get_reports.py +0 -181
- funapi_sciencedb-1.0.1/src/sciencedb/client.py +0 -286
- {funapi_sciencedb-1.0.1 → funapi_sciencedb-1.1.2}/LICENSE +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/api/open_api_controller/__init__.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/api/sushi_controller/__init__.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_attributes_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_contributors_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_dates_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_identifiers_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_instance_access_method.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_instance_metric_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_dataset_usage_data_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/counter_publisher_identifiers_type.py +0 -0
- {funapi_sciencedb-1.0.1/src/sciencedb → funapi_sciencedb-1.1.2/src/funapi_sciencedb}/models/sushi_error_model_severity.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: [farfarfun]
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.db
|
|
6
|
+
*.rar
|
|
7
|
+
.run/
|
|
8
|
+
logs/
|
|
9
|
+
.idea/
|
|
10
|
+
.vscode/
|
|
11
|
+
|
|
12
|
+
# C extensions
|
|
13
|
+
*.so
|
|
14
|
+
|
|
15
|
+
# Distribution / packaging
|
|
16
|
+
.Python
|
|
17
|
+
build/
|
|
18
|
+
develop-eggs/
|
|
19
|
+
dist/
|
|
20
|
+
downloads/
|
|
21
|
+
eggs/
|
|
22
|
+
.eggs/
|
|
23
|
+
lib/
|
|
24
|
+
lib64/
|
|
25
|
+
parts/
|
|
26
|
+
sdist/
|
|
27
|
+
var/
|
|
28
|
+
wheels/
|
|
29
|
+
share/python-wheels/
|
|
30
|
+
*.egg-info/
|
|
31
|
+
.installed.cfg
|
|
32
|
+
*.egg
|
|
33
|
+
MANIFEST
|
|
34
|
+
|
|
35
|
+
# PyInstaller
|
|
36
|
+
# Usually these files are written by a python script from a template
|
|
37
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
38
|
+
*.manifest
|
|
39
|
+
*.spec
|
|
40
|
+
|
|
41
|
+
# Installer logs
|
|
42
|
+
pip-log.txt
|
|
43
|
+
pip-delete-this-directory.txt
|
|
44
|
+
|
|
45
|
+
# Unit test / coverage reports
|
|
46
|
+
htmlcov/
|
|
47
|
+
.tox/
|
|
48
|
+
.nox/
|
|
49
|
+
.coverage
|
|
50
|
+
.coverage.*
|
|
51
|
+
.cache
|
|
52
|
+
nosetests.xml
|
|
53
|
+
coverage.xml
|
|
54
|
+
*.cover
|
|
55
|
+
*.py,cover
|
|
56
|
+
.hypothesis/
|
|
57
|
+
.pytest_cache/
|
|
58
|
+
cover/
|
|
59
|
+
|
|
60
|
+
# Translations
|
|
61
|
+
*.mo
|
|
62
|
+
*.pot
|
|
63
|
+
|
|
64
|
+
# Django stuff:
|
|
65
|
+
*.log
|
|
66
|
+
local_settings.py
|
|
67
|
+
db.sqlite3
|
|
68
|
+
db.sqlite3-journal
|
|
69
|
+
|
|
70
|
+
# Flask stuff:
|
|
71
|
+
instance/
|
|
72
|
+
.webassets-cache
|
|
73
|
+
|
|
74
|
+
# Scrapy stuff:
|
|
75
|
+
.scrapy
|
|
76
|
+
|
|
77
|
+
# Sphinx documentation
|
|
78
|
+
docs/_build/
|
|
79
|
+
|
|
80
|
+
# PyBuilder
|
|
81
|
+
.pybuilder/
|
|
82
|
+
target/
|
|
83
|
+
|
|
84
|
+
# Jupyter Notebook
|
|
85
|
+
.ipynb_checkpoints
|
|
86
|
+
|
|
87
|
+
# IPython
|
|
88
|
+
profile_default/
|
|
89
|
+
ipython_config.py
|
|
90
|
+
|
|
91
|
+
# pyenv
|
|
92
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
93
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
94
|
+
# .python-version
|
|
95
|
+
|
|
96
|
+
# pipenv
|
|
97
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
98
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
99
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
100
|
+
# install all needed dependencies.
|
|
101
|
+
#Pipfile.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# ---- AI 编码助手 ----
|
|
171
|
+
# 只忽略本地状态;团队有意共享的 agent / 命令 / 规则定义仍然版本化。
|
|
172
|
+
# 必须写 `dir/*` 而不是 `dir/`:父目录被整体排除后 git 不会下探,
|
|
173
|
+
# 下面的 `!` 取消规则就永远不会生效。
|
|
174
|
+
.claude/*
|
|
175
|
+
!.claude/agents/
|
|
176
|
+
!.claude/commands/
|
|
177
|
+
!.claude/skills/
|
|
178
|
+
!.claude/settings.json
|
|
179
|
+
.codex/*
|
|
180
|
+
!.codex/prompts/
|
|
181
|
+
.cursor/*
|
|
182
|
+
!.cursor/agents/
|
|
183
|
+
!.cursor/rules/
|
|
184
|
+
|
|
185
|
+
# 其余助手:目前没有共享内容,整体忽略
|
|
186
|
+
.aider*
|
|
187
|
+
.gemini/
|
|
188
|
+
.continue/
|
|
189
|
+
.windsurf/
|
|
190
|
+
.roo/
|
|
191
|
+
.cline/
|
|
192
|
+
.specstory/
|
|
193
|
+
CLAUDE.local.md
|
|
194
|
+
AGENTS.local.md
|
|
195
|
+
uv.lock
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.1.2] - 2026-11-12
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- 生成的客户端代码 docstring 全面中文化(SPEC §7)。此前只有 `client.py` 的两个类
|
|
8
|
+
docstring 和 `search_using_get.py` 被手工翻过,其余 28 个文件(全部模型、
|
|
9
|
+
`sushi_controller` 下的接口、`errors.py`、`types.py`、各级 `__init__.py`)以及
|
|
10
|
+
`client.py` 的方法 docstring 都还是英文,而且手工翻译在下次重新生成时会被覆盖掉。
|
|
11
|
+
- `tests/test_smoke.py` 的模块/用例 docstring 与注释改为中文。
|
|
12
|
+
|
|
13
|
+
### 新增
|
|
14
|
+
|
|
15
|
+
- `localize.py`:生成产物中文化脚本,两张精确文案映射表分别处理上游 OpenAPI 文档里的
|
|
16
|
+
`summary` / `description` 和 `openapi-python-client` 模板写死的英文。`generate.py`
|
|
17
|
+
已接入——拉取文档后先中文化文档,生成代码后再中文化模板文案,所以重新生成客户端
|
|
18
|
+
不会再退回英文。映射表只做精确匹配,上游新增文案原样保留,
|
|
19
|
+
`uv run python localize.py --check` 可以把漏网的 docstring 列出来。
|
|
20
|
+
- `tests/test_localize.py`:覆盖中文化的幂等性、折行长文案的匹配、只改 docstring 不动
|
|
21
|
+
代码、未登记文案不乱翻,以及「已提交的生成代码里没有残留英文 docstring」这条守卫。
|
|
22
|
+
- 仓库根目录 `conftest.py`:把根目录加进 `sys.path`,让测试能 import 根目录下的
|
|
23
|
+
`generate` / `localize` 这两个开发期脚本。
|
|
24
|
+
|
|
25
|
+
### 变更
|
|
26
|
+
|
|
27
|
+
- `pyproject.toml` 补上 `authors` 与 `license-files = ["LICENSE"]`,构建产物的
|
|
28
|
+
METADATA 里才会带作者和许可证文件(SPEC §4.2)。
|
|
29
|
+
- `localize.py` 的状态/诊断输出改用 `farlog`(SPEC §8.1:不要裸 `print`,也不要裸用
|
|
30
|
+
标准库 `logging`)。logger 在 `main()` 里创建,这样单纯 import 本模块不会建
|
|
31
|
+
`logs/` 目录。`farlog` 只进 `dev` / `generate` 依赖组,不进发布包。
|
|
32
|
+
- `openapi-ori.json` / `openapi-v3.json` 里的接口与模型说明同步改为中文,并补上文件
|
|
33
|
+
末尾换行。
|
|
34
|
+
- README 的「重新生成客户端」补充中文化步骤与 `localize.py --check` 用法。
|
|
35
|
+
- `uv.lock` 中的传递依赖 urllib3 由 2.7.0 升到 2.8.0,修掉 GitHub dependabot 报出的
|
|
36
|
+
3 个漏洞(2 个 HIGH:`HTTPResponse.stream()/read_chunked()` 无界缓冲、HTTPS 代理的
|
|
37
|
+
TLS 配置可能被忽略;1 个 MEDIUM:chunked deflate 可进入无限循环)。本包代码未改动。
|
|
38
|
+
- `generate.py`、`localize.py`、`tests/test_localize.py` 按仓库当前 ruff 配置补跑
|
|
39
|
+
`ruff format`,清掉一直存在的格式漂移,SPEC §14.2 发布前清单的
|
|
40
|
+
`ruff format` 一项现在能通过。纯格式化,无行为变更。
|
|
41
|
+
|
|
42
|
+
### 废弃
|
|
43
|
+
|
|
44
|
+
- 无。
|
|
45
|
+
|
|
46
|
+
## [1.1.1] - 2026-09-03
|
|
47
|
+
|
|
48
|
+
### 修复
|
|
49
|
+
|
|
50
|
+
- `generate.py` 不再把 `acw_tc`、`cdn_sec_tc` 这两个反爬会话 cookie 和 `traceId`
|
|
51
|
+
写死在代码里,改为从环境变量(`SCIDB_ACW_TC` / `SCIDB_CDN_SEC_TC`)读取,
|
|
52
|
+
`traceId` 每次运行随机生成。
|
|
53
|
+
- `pyproject.toml` 的 `description` 从占位符 `Add your description here` 改成
|
|
54
|
+
实际的中文一句话说明,并同步更新了 GitHub 仓库的 description。
|
|
55
|
+
- `sciencedb` 兼容层的 `DeprecationWarning` 明确了移除版本:将于 2.0 移除
|
|
56
|
+
(此前只写“未来某个版本”)。
|
|
57
|
+
|
|
58
|
+
### 新增
|
|
59
|
+
|
|
60
|
+
- README 补充「重新生成客户端」使用说明,以及末尾统一的「关于 farfarfun」组织
|
|
61
|
+
介绍区块。
|
|
62
|
+
- `generate.py` 运行所需的 `requests`、`funapi`、`openapi-python-client` 纳入
|
|
63
|
+
`pyproject.toml` 的 `generate` 依赖组,`uv sync --group generate` 即可复现。
|
|
64
|
+
- `tests/test_smoke.py` 补充 `metrics_using_get`、`json_using_get`、
|
|
65
|
+
`get_reports`、`get_report_by_id_using_get` 以及 `asyncio`/`asyncio_detailed`
|
|
66
|
+
异步调用路径的 mock HTTP 测试。
|
|
67
|
+
|
|
68
|
+
### 变更
|
|
69
|
+
|
|
70
|
+
- `pyproject.toml` 补充 `license = "MIT"` 字段。
|
|
71
|
+
- `[tool.ruff]` 按 Python 3.10 规则检查生成客户端代码。
|
|
72
|
+
- 本文件历史条目按「新增/修复/变更/废弃」四分类重新归类整理,不改变实际内容含义。
|
|
73
|
+
|
|
74
|
+
### 废弃
|
|
75
|
+
|
|
76
|
+
- 无。
|
|
77
|
+
|
|
78
|
+
## [1.1.0] - 2026-08-28
|
|
79
|
+
|
|
80
|
+
### 变更(破坏性变更)
|
|
81
|
+
|
|
82
|
+
- 包内导入路径从 `sciencedb` 统一改为 `funapi_sciencedb`,与仓库名、PyPI 发布名
|
|
83
|
+
(一直都是 `funapi-sciencedb`)保持一致。`generate.py` 里 OpenAPI 客户端代码的
|
|
84
|
+
生成目标目录也同步改为 `src/funapi_sciencedb`,以后重新生成不会再退回旧名。
|
|
85
|
+
|
|
86
|
+
### 新增
|
|
87
|
+
|
|
88
|
+
- 保留了 `sciencedb` 兼容层(`src/sciencedb/__init__.py`,仅一个文件):
|
|
89
|
+
`import sciencedb` 仍然可用,会转发到 `funapi_sciencedb` 并抛出
|
|
90
|
+
`DeprecationWarning`。计划在下一次破坏性版本中删除这个兼容层,请尽快把代码里的
|
|
91
|
+
`import sciencedb` / `from sciencedb...` 换成
|
|
92
|
+
`import funapi_sciencedb` / `from funapi_sciencedb...`。
|
|
93
|
+
|
|
94
|
+
### 修复
|
|
95
|
+
|
|
96
|
+
- 无。
|
|
97
|
+
|
|
98
|
+
### 废弃
|
|
99
|
+
|
|
100
|
+
- `sciencedb` 兼容导入将在 2.0 移除,请迁移到 `funapi_sciencedb`。
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: funapi-sciencedb
|
|
3
|
+
Version: 1.1.2
|
|
4
|
+
Summary: 科学数据银行(ScienceDB)Open API 的 Python 客户端,由 openapi-python-client 根据官方 OpenAPI 文档自动生成
|
|
5
|
+
Author-email: 牛哥 <farfarfun@qq.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: attrs>=22.2.0
|
|
10
|
+
Requires-Dist: httpx>=0.20.0
|
|
11
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# funapi-sciencedb
|
|
15
|
+
|
|
16
|
+
科学数据银行([ScienceDB](https://www.scidb.cn))Open API 的 Python 客户端,由 `openapi-python-client` 根据 ScienceDB 官方 OpenAPI 文档(`https://www.scidb.cn/open-api/v2/api-docs`)自动生成,仓库里的 `generate.py` 就是重新拉取该文档并重新生成客户端代码的脚本。
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install funapi-sciencedb
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 用法示例
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from funapi_sciencedb import Client
|
|
28
|
+
from funapi_sciencedb.api.open_api_controller import search_using_get
|
|
29
|
+
|
|
30
|
+
client = Client(base_url="https://www.scidb.cn/open-api/v2")
|
|
31
|
+
|
|
32
|
+
# 按发布时间倒序分页搜索数据集
|
|
33
|
+
result = search_using_get.sync(client=client, page=1, size=10)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
除了开放接口(`open_api_controller`,搜索/harvest/metrics/json 等),还包含 COUNTER 标准的用量统计报表接口(`sushi_controller`:`get_api_status`、`get_reports`、`get_report_by_id_using_get`)。每个接口都提供 `sync` / `sync_detailed` / `asyncio` / `asyncio_detailed` 四种调用方式,返回值是 `models/` 目录下对应的强类型模型对象。
|
|
37
|
+
|
|
38
|
+
由于是自动生成的客户端,具体字段和返回结构以 `src/funapi_sciencedb/models/` 下的类定义为准。
|
|
39
|
+
|
|
40
|
+
## 重新生成客户端
|
|
41
|
+
|
|
42
|
+
`generate.py` 会重新拉取 ScienceDB 官方 OpenAPI 文档并重新生成 `src/funapi_sciencedb/` 下的全部代码,运行前需要安装 `generate` 依赖组:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv sync --group generate
|
|
46
|
+
uv run python generate.py
|
|
47
|
+
ruff check --fix . && ruff format .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
生成器模板和上游 OpenAPI 文档都是英文的,`generate.py` 会自动调用 `localize.py` 把 docstring 换成中文:拉取文档后替换文档里的 `summary` / `description`,生成代码后再替换模板自带的 `Args:`、`Client` 类说明等。
|
|
51
|
+
|
|
52
|
+
映射表是精确匹配的,上游新增文案不会被瞎翻、而是原样保留。补完映射后可以单独重跑或自查:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv run python localize.py # 重新应用中文化
|
|
56
|
+
uv run python localize.py --check # 只检查,列出还没中文化的 docstring
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 关于 farfarfun
|
|
62
|
+
|
|
63
|
+
[farfarfun](https://github.com/farfarfun) 是一个专注于实用工具库的开源组织,
|
|
64
|
+
涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
|
|
65
|
+
|
|
66
|
+
- 🏠 组织主页:<https://github.com/farfarfun>
|
|
67
|
+
- 📦 PyPI:<https://pypi.org/user/niuliangtao/>
|
|
68
|
+
- 📧 联系:farfarfun@qq.com
|
|
69
|
+
|
|
70
|
+
本项目基于 [MIT](LICENSE) 协议开源。
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# funapi-sciencedb
|
|
2
|
+
|
|
3
|
+
科学数据银行([ScienceDB](https://www.scidb.cn))Open API 的 Python 客户端,由 `openapi-python-client` 根据 ScienceDB 官方 OpenAPI 文档(`https://www.scidb.cn/open-api/v2/api-docs`)自动生成,仓库里的 `generate.py` 就是重新拉取该文档并重新生成客户端代码的脚本。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install funapi-sciencedb
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 用法示例
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from funapi_sciencedb import Client
|
|
15
|
+
from funapi_sciencedb.api.open_api_controller import search_using_get
|
|
16
|
+
|
|
17
|
+
client = Client(base_url="https://www.scidb.cn/open-api/v2")
|
|
18
|
+
|
|
19
|
+
# 按发布时间倒序分页搜索数据集
|
|
20
|
+
result = search_using_get.sync(client=client, page=1, size=10)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
除了开放接口(`open_api_controller`,搜索/harvest/metrics/json 等),还包含 COUNTER 标准的用量统计报表接口(`sushi_controller`:`get_api_status`、`get_reports`、`get_report_by_id_using_get`)。每个接口都提供 `sync` / `sync_detailed` / `asyncio` / `asyncio_detailed` 四种调用方式,返回值是 `models/` 目录下对应的强类型模型对象。
|
|
24
|
+
|
|
25
|
+
由于是自动生成的客户端,具体字段和返回结构以 `src/funapi_sciencedb/models/` 下的类定义为准。
|
|
26
|
+
|
|
27
|
+
## 重新生成客户端
|
|
28
|
+
|
|
29
|
+
`generate.py` 会重新拉取 ScienceDB 官方 OpenAPI 文档并重新生成 `src/funapi_sciencedb/` 下的全部代码,运行前需要安装 `generate` 依赖组:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv sync --group generate
|
|
33
|
+
uv run python generate.py
|
|
34
|
+
ruff check --fix . && ruff format .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
生成器模板和上游 OpenAPI 文档都是英文的,`generate.py` 会自动调用 `localize.py` 把 docstring 换成中文:拉取文档后替换文档里的 `summary` / `description`,生成代码后再替换模板自带的 `Args:`、`Client` 类说明等。
|
|
38
|
+
|
|
39
|
+
映射表是精确匹配的,上游新增文案不会被瞎翻、而是原样保留。补完映射后可以单独重跑或自查:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv run python localize.py # 重新应用中文化
|
|
43
|
+
uv run python localize.py --check # 只检查,列出还没中文化的 docstring
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 关于 farfarfun
|
|
49
|
+
|
|
50
|
+
[farfarfun](https://github.com/farfarfun) 是一个专注于实用工具库的开源组织,
|
|
51
|
+
涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
|
|
52
|
+
|
|
53
|
+
- 🏠 组织主页:<https://github.com/farfarfun>
|
|
54
|
+
- 📦 PyPI:<https://pypi.org/user/niuliangtao/>
|
|
55
|
+
- 📧 联系:farfarfun@qq.com
|
|
56
|
+
|
|
57
|
+
本项目基于 [MIT](LICENSE) 协议开源。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""把仓库根目录加进 `sys.path`,让测试能 import 根目录下的 `generate` / `localize`。
|
|
2
|
+
|
|
3
|
+
这两个模块是开发期脚本(不进发布包),所以不在 `src/` 里,默认不在导入路径上。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
ROOT = Path(__file__).parent
|
|
10
|
+
if str(ROOT) not in sys.path:
|
|
11
|
+
sys.path.insert(0, str(ROOT))
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import uuid
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
from funapi.convert import convert_openapi_v3
|
|
8
|
+
from funapi.generate import generate_api
|
|
9
|
+
from openapi_python_client import MetaType
|
|
10
|
+
|
|
11
|
+
from localize import localize_generated, localize_openapi
|
|
12
|
+
|
|
13
|
+
OPENAPI_FILEPATH_ORI = "openapi-ori.json"
|
|
14
|
+
OPENAPI_FILEPATH_V3 = "openapi-v3.json"
|
|
15
|
+
OUTPUT_DIR = Path("./src/funapi_sciencedb")
|
|
16
|
+
OPENAPI_REQUEST_TIMEOUT = 30
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_openapi_ori() -> None:
|
|
20
|
+
"""拉取 ScienceDB 官方 OpenAPI 文档,写入本地 `openapi-ori.json`。
|
|
21
|
+
|
|
22
|
+
`acw_tc` / `cdn_sec_tc` 是阿里云 WAF 下发的反爬会话 cookie(不是账号凭据),
|
|
23
|
+
每次访问都会重新生成、很快过期,不应该写死在代码里。这里改为从环境变量读取,
|
|
24
|
+
留空时也能直接访问——大多数情况下 ScienceDB 的这个文档地址不依赖这两个 cookie
|
|
25
|
+
也能正常返回;如果本地实测确实需要,临时用
|
|
26
|
+
`SCIDB_ACW_TC` / `SCIDB_CDN_SEC_TC` 环境变量传入即可,不要提交到仓库。
|
|
27
|
+
"""
|
|
28
|
+
url = "https://www.scidb.cn/open-api/v2/api-docs"
|
|
29
|
+
headers = {
|
|
30
|
+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
31
|
+
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
32
|
+
"cache-control": "max-age=0",
|
|
33
|
+
"priority": "u=0, i",
|
|
34
|
+
"referer": "https://www.scidb.cn/open-api/swagger-ui.html",
|
|
35
|
+
"sec-ch-ua": '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
|
|
36
|
+
"sec-ch-ua-mobile": "?1",
|
|
37
|
+
"sec-ch-ua-platform": '"Android"',
|
|
38
|
+
"sec-fetch-dest": "document",
|
|
39
|
+
"sec-fetch-mode": "navigate",
|
|
40
|
+
"sec-fetch-site": "same-origin",
|
|
41
|
+
"sec-fetch-user": "?1",
|
|
42
|
+
"upgrade-insecure-requests": "1",
|
|
43
|
+
"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36",
|
|
44
|
+
}
|
|
45
|
+
cookies = {
|
|
46
|
+
"acw_tc": os.environ.get("SCIDB_ACW_TC", ""),
|
|
47
|
+
"cdn_sec_tc": os.environ.get("SCIDB_CDN_SEC_TC", ""),
|
|
48
|
+
"lang": "zh",
|
|
49
|
+
"traceId": str(uuid.uuid4()),
|
|
50
|
+
}
|
|
51
|
+
cookies = {k: v for k, v in cookies.items() if v}
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
response = requests.get(
|
|
55
|
+
url,
|
|
56
|
+
headers=headers,
|
|
57
|
+
cookies=cookies,
|
|
58
|
+
timeout=OPENAPI_REQUEST_TIMEOUT,
|
|
59
|
+
)
|
|
60
|
+
response.raise_for_status()
|
|
61
|
+
except requests.HTTPError as exc:
|
|
62
|
+
status = exc.response.status_code if exc.response is not None else "未知"
|
|
63
|
+
raise RuntimeError(
|
|
64
|
+
f"下载 ScienceDB OpenAPI 文档失败:{url}(HTTP {status},{exc})"
|
|
65
|
+
) from exc
|
|
66
|
+
except requests.RequestException as exc:
|
|
67
|
+
raise RuntimeError(f"下载 ScienceDB OpenAPI 文档失败:{url}({exc})") from exc
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
openapi = response.json()
|
|
71
|
+
except ValueError as exc:
|
|
72
|
+
raise RuntimeError(
|
|
73
|
+
f"ScienceDB OpenAPI 文档不是合法 JSON:{url}(HTTP {response.status_code})"
|
|
74
|
+
) from exc
|
|
75
|
+
# 上游文档是英文的,先按 localize.py 的映射表换成中文再落盘,这样后面生成出来的
|
|
76
|
+
# docstring 直接就是中文(SPEC §7),不用事后再补。
|
|
77
|
+
openapi = localize_openapi(openapi)
|
|
78
|
+
with open(OPENAPI_FILEPATH_ORI, "w", encoding="utf-8") as f:
|
|
79
|
+
f.write(json.dumps(openapi, indent=4, ensure_ascii=False) + "\n")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def main() -> None:
|
|
83
|
+
"""拉取并转换 OpenAPI 文档,然后重新生成客户端代码。"""
|
|
84
|
+
load_openapi_ori()
|
|
85
|
+
convert_openapi_v3()
|
|
86
|
+
generate_api(
|
|
87
|
+
path=Path(OPENAPI_FILEPATH_V3),
|
|
88
|
+
output_path=OUTPUT_DIR,
|
|
89
|
+
meta=MetaType.NONE,
|
|
90
|
+
overwrite=True,
|
|
91
|
+
)
|
|
92
|
+
# 生成器模板自带的英文(`Args:`、`Client` 类说明等)不在 OpenAPI 文档里,
|
|
93
|
+
# 只能生成完再替换一遍。
|
|
94
|
+
localize_generated(OUTPUT_DIR)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
main()
|