python-re3data-v2 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.
- python_re3data_v2-0.1.0/.gitignore +20 -0
- python_re3data_v2-0.1.0/LICENSE +21 -0
- python_re3data_v2-0.1.0/PKG-INFO +215 -0
- python_re3data_v2-0.1.0/README.md +188 -0
- python_re3data_v2-0.1.0/pyproject.toml +150 -0
- python_re3data_v2-0.1.0/src/re3data/__init__.py +31 -0
- python_re3data_v2-0.1.0/src/re3data/__main__.py +6 -0
- python_re3data_v2-0.1.0/src/re3data/_cli.py +114 -0
- python_re3data_v2-0.1.0/src/re3data/_client/__init__.py +14 -0
- python_re3data_v2-0.1.0/src/re3data/_client/_async.py +143 -0
- python_re3data_v2-0.1.0/src/re3data/_client/_sync.py +145 -0
- python_re3data_v2-0.1.0/src/re3data/_client/base.py +152 -0
- python_re3data_v2-0.1.0/src/re3data/_exceptions.py +9 -0
- python_re3data_v2-0.1.0/src/re3data/_parser.py +443 -0
- python_re3data_v2-0.1.0/src/re3data/_resources/__init__.py +19 -0
- python_re3data_v2-0.1.0/src/re3data/_resources/repository.py +564 -0
- python_re3data_v2-0.1.0/src/re3data/_resources/repository_list.py +66 -0
- python_re3data_v2-0.1.0/src/re3data/_response.py +34 -0
- python_re3data_v2-0.1.0/src/re3data/_serializer.py +82 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 data-sync maintainers
|
|
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,215 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: python-re3data-v2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Pythonic client for the re3data API (v40, schema 4.0).
|
|
5
|
+
Project-URL: Changelog, https://github.com/AstrayChao/python-re3data-v2/blob/master/CHANGELOG.md
|
|
6
|
+
Project-URL: Repository, https://github.com/AstrayChao/python-re3data-v2
|
|
7
|
+
Project-URL: Issues, https://github.com/AstrayChao/python-re3data-v2/issues
|
|
8
|
+
Author: data-sync maintainers
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,api-client,metadata,re3data,repositories,research data
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup :: XML
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.14
|
|
21
|
+
Requires-Dist: httpx>=0.28
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: typer>=0.16; extra == 'all'
|
|
24
|
+
Provides-Extra: cli
|
|
25
|
+
Requires-Dist: typer>=0.16; extra == 'cli'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
|
|
30
|
+
# python-re3data-v2
|
|
31
|
+
|
|
32
|
+
**The Pythonic client for the [re3data](https://www.re3data.org) API — v40 · schema 4.0 · Python 3.14+**
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/python-re3data-v2/)
|
|
35
|
+
[](pyproject.toml)
|
|
36
|
+
[](https://github.com/AstrayChao/python-re3data-v2/actions/workflows/test.yml)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
[](https://docs.astral.sh/ruff/)
|
|
39
|
+
[](https://github.com/afuetterer/python-re3data)
|
|
40
|
+
|
|
41
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
> [!NOTE]
|
|
48
|
+
> **Why this fork exists** — the original client [`python-re3data`](https://github.com/afuetterer/python-re3data)
|
|
49
|
+
> by Heinz-Alexander Fütterer (MIT) has been **archived** and targets the deprecated
|
|
50
|
+
> `/api/beta` endpoints (schema 2-2). This repository is an independent re-implementation,
|
|
51
|
+
> built from scratch against the current **v40 REST API** and the
|
|
52
|
+
> [re3data metadata schema 4.0](https://doi.org/10.48440/re3.014), keeping the familiar
|
|
53
|
+
> architecture and dict conventions of the original.
|
|
54
|
+
|
|
55
|
+
> [!WARNING]
|
|
56
|
+
> **Not production-ready yet.** This library is young: the v40 API and schema 4.0 are new,
|
|
57
|
+
> and edge cases may still exist. **Use with caution in production environments until the
|
|
58
|
+
> first stable release.** 非正式发布阶段,请谨慎用于生产环境。
|
|
59
|
+
|
|
60
|
+
## ✨ Highlights
|
|
61
|
+
|
|
62
|
+
| | |
|
|
63
|
+
|---|---|
|
|
64
|
+
| 🚀 **v40 endpoints** | `GET /api/v40/repositories` · `GET /api/v40/repository/{id}` |
|
|
65
|
+
| 🧬 **Typed schema 4.0 models** | Hand-written dataclasses mirroring the [official XSD](https://schema.re3data.org/4-0/re3dataV4-0.xsd) — no `xsdata` |
|
|
66
|
+
| 🛡️ **Drift-tolerant parsing** | Unknown vocabulary values / malformed dates never break a parse |
|
|
67
|
+
| ⚡ **Sync + async** | `Client` and `AsyncClient` on top of `httpx` |
|
|
68
|
+
| 🔄 **Flexible serialization** | `dataclass` · `dict` · `json` · `xml` · `csv` · `response` |
|
|
69
|
+
| 🎛️ **Facet filters** | ~30 v40 filter facets via a single `filters` mapping |
|
|
70
|
+
| 🪶 **Minimal footprint** | Python 3.14+, the only runtime dependency is `httpx` |
|
|
71
|
+
|
|
72
|
+
## 📦 Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install python-re3data-v2 # or: uv add python-re3data-v2
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
With the optional CLI:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install 'python-re3data-v2[cli]'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 🚀 Quick start
|
|
85
|
+
|
|
86
|
+
### Module-level manager (synchronous)
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import re3data
|
|
90
|
+
|
|
91
|
+
summaries = re3data.repositories.list(query="UCL")
|
|
92
|
+
for summary in summaries:
|
|
93
|
+
print(summary.id, summary.doi, summary.name, summary.href)
|
|
94
|
+
|
|
95
|
+
repository = re3data.repositories.get("r3d100012417")
|
|
96
|
+
print(repository.repositoryName.value) # "UCL Discovery"
|
|
97
|
+
print(repository.identifiers.doi) # "https://doi.org/10.17616/R34F41"
|
|
98
|
+
print(repository.subject[0].subjectId) # "4" (DFG classification id)
|
|
99
|
+
print(repository.entryDate) # datetime.date(2017, 7, 21)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Explicit clients
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from re3data import Client, AsyncClient
|
|
106
|
+
|
|
107
|
+
client = Client()
|
|
108
|
+
repository = client.repositories.get("r3d100012417")
|
|
109
|
+
|
|
110
|
+
async with AsyncClient() as async_client:
|
|
111
|
+
repository = await async_client.repositories.get("r3d100012417")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Return types
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from re3data import Client, ReturnType
|
|
118
|
+
|
|
119
|
+
client = Client()
|
|
120
|
+
payload = client.repositories.get("r3d100012417", return_type=ReturnType.DICT)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`ReturnType.DICT` reproduces the document with XML-style keys (`repositoryUrl`,
|
|
124
|
+
`identifiers.re3data`, `subject[].subjectId`, …), localized elements as
|
|
125
|
+
`{"value": ..., "language": ...}` and dates as ISO-8601 strings — the same
|
|
126
|
+
conventions the original `python-re3data` established, so existing consumers
|
|
127
|
+
keep working with minimal changes.
|
|
128
|
+
|
|
129
|
+
### Facet filters
|
|
130
|
+
|
|
131
|
+
The v40 list endpoint supports ~30 facet filters, serialized as repeated
|
|
132
|
+
`name[]` query parameters:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
client.repositories.list(
|
|
136
|
+
query="climate",
|
|
137
|
+
filters={"countries": ["DEU", "NZL"], "certificates": "CoreTrustSeal"},
|
|
138
|
+
)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### CLI
|
|
142
|
+
|
|
143
|
+
```console
|
|
144
|
+
$ re3data repository get r3d100012417 --return-type json
|
|
145
|
+
$ re3data repository list --query "UCL" --return-type csv
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 🔀 Differences vs. the original `python-re3data`
|
|
149
|
+
|
|
150
|
+
| Aspect | python-re3data 0.10 | python-re3data-v2 |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| API | `/api/beta` (deprecated) | `/api/v40` (current) |
|
|
153
|
+
| Metadata schema | 2-2 | **4.0** (August 2023) |
|
|
154
|
+
| Python | ≥ 3.10 | **≥ 3.14** |
|
|
155
|
+
| XML binding | `xsdata` codegen | stdlib `ElementTree` + hand-written models |
|
|
156
|
+
| List entry fields | id, doi, link | id, doi, **name**, link |
|
|
157
|
+
| `dataframe` return type | ✅ (requires pandas) | ❌ (dropped; `csv` is built-in) |
|
|
158
|
+
| Facet filters | `query` only | `query` + `filters` mapping |
|
|
159
|
+
|
|
160
|
+
A complete field-by-field mapping between schema 2-2 and 4.0 is available in
|
|
161
|
+
[docs/schema-mapping.md](docs/schema-mapping.md); the underlying research and
|
|
162
|
+
migration notes live in [docs/research.md](docs/research.md).
|
|
163
|
+
|
|
164
|
+
## ⚠️ Known upstream issues
|
|
165
|
+
|
|
166
|
+
- `GET /api/v40/repositories` **without** a `query`/filter currently fails with
|
|
167
|
+
HTTP 500 server-side (the deprecated beta endpoint behaves the same). Listing
|
|
168
|
+
everything therefore requires a query or filter for now; the client surfaces
|
|
169
|
+
the error transparently.
|
|
170
|
+
- The API only serves `application/xml` — there is no JSON representation.
|
|
171
|
+
- Live data occasionally deviates from the XSD vocabularies (e.g.
|
|
172
|
+
`"institutional membership"` vs. `"institutionalMembership"`). Vocabulary
|
|
173
|
+
fields are typed as plain `str` and parsed verbatim, so unknown values never
|
|
174
|
+
raise.
|
|
175
|
+
|
|
176
|
+
## 📚 API reference
|
|
177
|
+
|
|
178
|
+
`re3data.repositories` · `re3data.Client` · `re3data.AsyncClient`
|
|
179
|
+
|
|
180
|
+
| Method | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `repositories.list(query=None, filters=None, return_type=..., count=False)` | List repositories, optionally filtered |
|
|
183
|
+
| `repositories.get(repository_id, return_type=...)` | Fetch one repository by its re3data id |
|
|
184
|
+
|
|
185
|
+
<details>
|
|
186
|
+
<summary>Reference enums exported for convenience</summary>
|
|
187
|
+
|
|
188
|
+
`RepositoryType`, `ProviderType`, `DatabaseAccessType`, `DatabaseAccessRestriction`,
|
|
189
|
+
`DataAccessType`, `DataAccessRestriction`, `DataUploadType`, `DataUploadRestriction`,
|
|
190
|
+
`InstitutionType`, `ResponsibilityType`, `RelatedRepositoryType`, `YesNo`
|
|
191
|
+
|
|
192
|
+
</details>
|
|
193
|
+
|
|
194
|
+
## 🛠️ Development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
uv sync --all-groups # Python 3.14 environment
|
|
198
|
+
uv run pytest # unit + integration (offline, real v40 XML fixtures)
|
|
199
|
+
uv run pytest -m e2e # live API smoke tests
|
|
200
|
+
uv run ruff check . # lint
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 📄 License
|
|
204
|
+
|
|
205
|
+
[MIT](LICENSE) — same as the original project. The architecture and dict
|
|
206
|
+
conventions are deliberately compatible with
|
|
207
|
+
[python-re3data](https://github.com/afuetterer/python-re3data) by
|
|
208
|
+
Heinz-Alexander Fütterer; this repository shares no code with it.
|
|
209
|
+
|
|
210
|
+
## 🙏 Credits
|
|
211
|
+
|
|
212
|
+
- [python-re3data](https://github.com/afuetterer/python-re3data) — the original
|
|
213
|
+
Pythonic client this project continues, in spirit and API shape.
|
|
214
|
+
- [re3data.org](https://www.re3data.org) — registry of research data
|
|
215
|
+
repositories, Karlsruhe Institute of Technology / FIZ Karlsruhe.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# python-re3data-v2
|
|
4
|
+
|
|
5
|
+
**The Pythonic client for the [re3data](https://www.re3data.org) API — v40 · schema 4.0 · Python 3.14+**
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/python-re3data-v2/)
|
|
8
|
+
[](pyproject.toml)
|
|
9
|
+
[](https://github.com/AstrayChao/python-re3data-v2/actions/workflows/test.yml)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://docs.astral.sh/ruff/)
|
|
12
|
+
[](https://github.com/afuetterer/python-re3data)
|
|
13
|
+
|
|
14
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
> [!NOTE]
|
|
21
|
+
> **Why this fork exists** — the original client [`python-re3data`](https://github.com/afuetterer/python-re3data)
|
|
22
|
+
> by Heinz-Alexander Fütterer (MIT) has been **archived** and targets the deprecated
|
|
23
|
+
> `/api/beta` endpoints (schema 2-2). This repository is an independent re-implementation,
|
|
24
|
+
> built from scratch against the current **v40 REST API** and the
|
|
25
|
+
> [re3data metadata schema 4.0](https://doi.org/10.48440/re3.014), keeping the familiar
|
|
26
|
+
> architecture and dict conventions of the original.
|
|
27
|
+
|
|
28
|
+
> [!WARNING]
|
|
29
|
+
> **Not production-ready yet.** This library is young: the v40 API and schema 4.0 are new,
|
|
30
|
+
> and edge cases may still exist. **Use with caution in production environments until the
|
|
31
|
+
> first stable release.** 非正式发布阶段,请谨慎用于生产环境。
|
|
32
|
+
|
|
33
|
+
## ✨ Highlights
|
|
34
|
+
|
|
35
|
+
| | |
|
|
36
|
+
|---|---|
|
|
37
|
+
| 🚀 **v40 endpoints** | `GET /api/v40/repositories` · `GET /api/v40/repository/{id}` |
|
|
38
|
+
| 🧬 **Typed schema 4.0 models** | Hand-written dataclasses mirroring the [official XSD](https://schema.re3data.org/4-0/re3dataV4-0.xsd) — no `xsdata` |
|
|
39
|
+
| 🛡️ **Drift-tolerant parsing** | Unknown vocabulary values / malformed dates never break a parse |
|
|
40
|
+
| ⚡ **Sync + async** | `Client` and `AsyncClient` on top of `httpx` |
|
|
41
|
+
| 🔄 **Flexible serialization** | `dataclass` · `dict` · `json` · `xml` · `csv` · `response` |
|
|
42
|
+
| 🎛️ **Facet filters** | ~30 v40 filter facets via a single `filters` mapping |
|
|
43
|
+
| 🪶 **Minimal footprint** | Python 3.14+, the only runtime dependency is `httpx` |
|
|
44
|
+
|
|
45
|
+
## 📦 Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install python-re3data-v2 # or: uv add python-re3data-v2
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
With the optional CLI:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install 'python-re3data-v2[cli]'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🚀 Quick start
|
|
58
|
+
|
|
59
|
+
### Module-level manager (synchronous)
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import re3data
|
|
63
|
+
|
|
64
|
+
summaries = re3data.repositories.list(query="UCL")
|
|
65
|
+
for summary in summaries:
|
|
66
|
+
print(summary.id, summary.doi, summary.name, summary.href)
|
|
67
|
+
|
|
68
|
+
repository = re3data.repositories.get("r3d100012417")
|
|
69
|
+
print(repository.repositoryName.value) # "UCL Discovery"
|
|
70
|
+
print(repository.identifiers.doi) # "https://doi.org/10.17616/R34F41"
|
|
71
|
+
print(repository.subject[0].subjectId) # "4" (DFG classification id)
|
|
72
|
+
print(repository.entryDate) # datetime.date(2017, 7, 21)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Explicit clients
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from re3data import Client, AsyncClient
|
|
79
|
+
|
|
80
|
+
client = Client()
|
|
81
|
+
repository = client.repositories.get("r3d100012417")
|
|
82
|
+
|
|
83
|
+
async with AsyncClient() as async_client:
|
|
84
|
+
repository = await async_client.repositories.get("r3d100012417")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Return types
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from re3data import Client, ReturnType
|
|
91
|
+
|
|
92
|
+
client = Client()
|
|
93
|
+
payload = client.repositories.get("r3d100012417", return_type=ReturnType.DICT)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`ReturnType.DICT` reproduces the document with XML-style keys (`repositoryUrl`,
|
|
97
|
+
`identifiers.re3data`, `subject[].subjectId`, …), localized elements as
|
|
98
|
+
`{"value": ..., "language": ...}` and dates as ISO-8601 strings — the same
|
|
99
|
+
conventions the original `python-re3data` established, so existing consumers
|
|
100
|
+
keep working with minimal changes.
|
|
101
|
+
|
|
102
|
+
### Facet filters
|
|
103
|
+
|
|
104
|
+
The v40 list endpoint supports ~30 facet filters, serialized as repeated
|
|
105
|
+
`name[]` query parameters:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
client.repositories.list(
|
|
109
|
+
query="climate",
|
|
110
|
+
filters={"countries": ["DEU", "NZL"], "certificates": "CoreTrustSeal"},
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### CLI
|
|
115
|
+
|
|
116
|
+
```console
|
|
117
|
+
$ re3data repository get r3d100012417 --return-type json
|
|
118
|
+
$ re3data repository list --query "UCL" --return-type csv
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 🔀 Differences vs. the original `python-re3data`
|
|
122
|
+
|
|
123
|
+
| Aspect | python-re3data 0.10 | python-re3data-v2 |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| API | `/api/beta` (deprecated) | `/api/v40` (current) |
|
|
126
|
+
| Metadata schema | 2-2 | **4.0** (August 2023) |
|
|
127
|
+
| Python | ≥ 3.10 | **≥ 3.14** |
|
|
128
|
+
| XML binding | `xsdata` codegen | stdlib `ElementTree` + hand-written models |
|
|
129
|
+
| List entry fields | id, doi, link | id, doi, **name**, link |
|
|
130
|
+
| `dataframe` return type | ✅ (requires pandas) | ❌ (dropped; `csv` is built-in) |
|
|
131
|
+
| Facet filters | `query` only | `query` + `filters` mapping |
|
|
132
|
+
|
|
133
|
+
A complete field-by-field mapping between schema 2-2 and 4.0 is available in
|
|
134
|
+
[docs/schema-mapping.md](docs/schema-mapping.md); the underlying research and
|
|
135
|
+
migration notes live in [docs/research.md](docs/research.md).
|
|
136
|
+
|
|
137
|
+
## ⚠️ Known upstream issues
|
|
138
|
+
|
|
139
|
+
- `GET /api/v40/repositories` **without** a `query`/filter currently fails with
|
|
140
|
+
HTTP 500 server-side (the deprecated beta endpoint behaves the same). Listing
|
|
141
|
+
everything therefore requires a query or filter for now; the client surfaces
|
|
142
|
+
the error transparently.
|
|
143
|
+
- The API only serves `application/xml` — there is no JSON representation.
|
|
144
|
+
- Live data occasionally deviates from the XSD vocabularies (e.g.
|
|
145
|
+
`"institutional membership"` vs. `"institutionalMembership"`). Vocabulary
|
|
146
|
+
fields are typed as plain `str` and parsed verbatim, so unknown values never
|
|
147
|
+
raise.
|
|
148
|
+
|
|
149
|
+
## 📚 API reference
|
|
150
|
+
|
|
151
|
+
`re3data.repositories` · `re3data.Client` · `re3data.AsyncClient`
|
|
152
|
+
|
|
153
|
+
| Method | Description |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `repositories.list(query=None, filters=None, return_type=..., count=False)` | List repositories, optionally filtered |
|
|
156
|
+
| `repositories.get(repository_id, return_type=...)` | Fetch one repository by its re3data id |
|
|
157
|
+
|
|
158
|
+
<details>
|
|
159
|
+
<summary>Reference enums exported for convenience</summary>
|
|
160
|
+
|
|
161
|
+
`RepositoryType`, `ProviderType`, `DatabaseAccessType`, `DatabaseAccessRestriction`,
|
|
162
|
+
`DataAccessType`, `DataAccessRestriction`, `DataUploadType`, `DataUploadRestriction`,
|
|
163
|
+
`InstitutionType`, `ResponsibilityType`, `RelatedRepositoryType`, `YesNo`
|
|
164
|
+
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
## 🛠️ Development
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
uv sync --all-groups # Python 3.14 environment
|
|
171
|
+
uv run pytest # unit + integration (offline, real v40 XML fixtures)
|
|
172
|
+
uv run pytest -m e2e # live API smoke tests
|
|
173
|
+
uv run ruff check . # lint
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 📄 License
|
|
177
|
+
|
|
178
|
+
[MIT](LICENSE) — same as the original project. The architecture and dict
|
|
179
|
+
conventions are deliberately compatible with
|
|
180
|
+
[python-re3data](https://github.com/afuetterer/python-re3data) by
|
|
181
|
+
Heinz-Alexander Fütterer; this repository shares no code with it.
|
|
182
|
+
|
|
183
|
+
## 🙏 Credits
|
|
184
|
+
|
|
185
|
+
- [python-re3data](https://github.com/afuetterer/python-re3data) — the original
|
|
186
|
+
Pythonic client this project continues, in spirit and API shape.
|
|
187
|
+
- [re3data.org](https://www.re3data.org) — registry of research data
|
|
188
|
+
repositories, Karlsruhe Institute of Technology / FIZ Karlsruhe.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# ------------------------------------------------------------------------------
|
|
2
|
+
# Build system
|
|
3
|
+
# ------------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
[build-system]
|
|
6
|
+
build-backend = "hatchling.build"
|
|
7
|
+
requires = [
|
|
8
|
+
"hatchling",
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
# ------------------------------------------------------------------------------
|
|
12
|
+
# Project
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
[project]
|
|
16
|
+
name = "python-re3data-v2"
|
|
17
|
+
version = "0.1.0"
|
|
18
|
+
description = "The Pythonic client for the re3data API (v40, schema 4.0)."
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
keywords = [
|
|
21
|
+
"api",
|
|
22
|
+
"api-client",
|
|
23
|
+
"metadata",
|
|
24
|
+
"re3data",
|
|
25
|
+
"repositories",
|
|
26
|
+
"research data",
|
|
27
|
+
]
|
|
28
|
+
license = "MIT"
|
|
29
|
+
license-files = [ "LICENSE" ]
|
|
30
|
+
authors = [
|
|
31
|
+
{ name = "data-sync maintainers" },
|
|
32
|
+
]
|
|
33
|
+
requires-python = ">=3.14"
|
|
34
|
+
classifiers = [
|
|
35
|
+
"Development Status :: 4 - Beta",
|
|
36
|
+
"Operating System :: OS Independent",
|
|
37
|
+
"Programming Language :: Python",
|
|
38
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
39
|
+
"Programming Language :: Python :: 3.14",
|
|
40
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
41
|
+
"Topic :: Text Processing :: Markup :: XML",
|
|
42
|
+
"Typing :: Typed",
|
|
43
|
+
]
|
|
44
|
+
dependencies = [
|
|
45
|
+
"httpx>=0.28",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
optional-dependencies.cli = [
|
|
49
|
+
"typer>=0.16",
|
|
50
|
+
]
|
|
51
|
+
optional-dependencies.all = [
|
|
52
|
+
"python-re3data-v2[cli]",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
urls.Changelog = "https://github.com/AstrayChao/python-re3data-v2/blob/master/CHANGELOG.md"
|
|
56
|
+
urls.Repository = "https://github.com/AstrayChao/python-re3data-v2"
|
|
57
|
+
urls.Issues = "https://github.com/AstrayChao/python-re3data-v2/issues"
|
|
58
|
+
scripts.re3data = "re3data.__main__:app"
|
|
59
|
+
|
|
60
|
+
[dependency-groups]
|
|
61
|
+
dev = [
|
|
62
|
+
"python-re3data-v2[all]",
|
|
63
|
+
"ruff>=0.14",
|
|
64
|
+
]
|
|
65
|
+
test = [
|
|
66
|
+
"pytest>=8.4",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
# ------------------------------------------------------------------------------
|
|
70
|
+
# Tooling
|
|
71
|
+
# ------------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
[tool.hatch.build.targets.sdist]
|
|
74
|
+
only-include = [
|
|
75
|
+
"src/re3data",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[tool.hatch.build.targets.wheel]
|
|
79
|
+
only-packages = true
|
|
80
|
+
packages = [
|
|
81
|
+
"src/re3data",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.ruff]
|
|
85
|
+
line-length = 120
|
|
86
|
+
src = [
|
|
87
|
+
"src",
|
|
88
|
+
"tests",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
[tool.ruff.lint]
|
|
92
|
+
# schema 4.0 mirror models intentionally use the XML camelCase names as field names
|
|
93
|
+
extend-ignore = [
|
|
94
|
+
"N803", # argument name should be lowercase — schema mirror fields
|
|
95
|
+
"N815", # mixedCase variable in class scope — schema mirror fields
|
|
96
|
+
]
|
|
97
|
+
extend-select = [
|
|
98
|
+
"A", # flake8-builtins
|
|
99
|
+
"B", # flake8-bugbear
|
|
100
|
+
"C4", # flake8-comprehensions
|
|
101
|
+
"I", # isort
|
|
102
|
+
"PERF", # perflint
|
|
103
|
+
"PL", # pylint
|
|
104
|
+
"PT", # flake8-pytest-style
|
|
105
|
+
"RET", # flake8-return
|
|
106
|
+
"RUF", # ruff
|
|
107
|
+
"SIM", # flake8-simplify
|
|
108
|
+
"UP", # pyupgrade
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[tool.ruff.lint.per-file-ignores]
|
|
112
|
+
"src/re3data/_resources/*.py" = [
|
|
113
|
+
"D101", # undocumented-public-class — schema mirrors are documented by the XSD
|
|
114
|
+
"D106", # undocumented-public-nested-class
|
|
115
|
+
]
|
|
116
|
+
"tests/**.py" = [
|
|
117
|
+
"D", # pydocstyle
|
|
118
|
+
"PLR2004", # magic-value-comparison
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
[tool.pytest.ini_options]
|
|
122
|
+
minversion = "8.0"
|
|
123
|
+
addopts = [
|
|
124
|
+
"-ra",
|
|
125
|
+
"--showlocals",
|
|
126
|
+
"--strict-markers",
|
|
127
|
+
"--strict-config",
|
|
128
|
+
"-m not e2e",
|
|
129
|
+
]
|
|
130
|
+
filterwarnings = [
|
|
131
|
+
"error",
|
|
132
|
+
]
|
|
133
|
+
log_cli_level = "INFO"
|
|
134
|
+
testpaths = "tests"
|
|
135
|
+
markers = [
|
|
136
|
+
"e2e: marks tests as end-to-end tests, requesting the live api",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[tool.coverage.run]
|
|
140
|
+
branch = true
|
|
141
|
+
source = [
|
|
142
|
+
"re3data",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
[tool.coverage.report]
|
|
146
|
+
exclude_also = [
|
|
147
|
+
"if TYPE_CHECKING:",
|
|
148
|
+
"@overload",
|
|
149
|
+
]
|
|
150
|
+
show_missing = true
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""python-re3data-v2: the Pythonic client for the re3data API (v40, schema 4.0)."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__: str = version("python-re3data-v2")
|
|
7
|
+
except PackageNotFoundError: # pragma: no cover - package not installed
|
|
8
|
+
__version__ = "0.0.0"
|
|
9
|
+
|
|
10
|
+
from re3data._client import AsyncClient, Client, ReturnType
|
|
11
|
+
from re3data._exceptions import Re3dataError, RepositoryNotFoundError
|
|
12
|
+
from re3data._resources import Link, Re3Data, Repository, RepositoryList, RepositorySummary
|
|
13
|
+
from re3data._response import Response
|
|
14
|
+
|
|
15
|
+
__all__ = (
|
|
16
|
+
"AsyncClient",
|
|
17
|
+
"Client",
|
|
18
|
+
"Link",
|
|
19
|
+
"Re3Data",
|
|
20
|
+
"Re3dataError",
|
|
21
|
+
"Repository",
|
|
22
|
+
"RepositoryList",
|
|
23
|
+
"RepositoryNotFoundError",
|
|
24
|
+
"RepositorySummary",
|
|
25
|
+
"Response",
|
|
26
|
+
"ReturnType",
|
|
27
|
+
"__version__",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
_client = Client()
|
|
31
|
+
repositories = _client.repositories
|