portolan-python 0.1.5__tar.gz → 0.1.6__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.
- {portolan_python-0.1.5 → portolan_python-0.1.6}/.coverage +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/PKG-INFO +1 -1
- {portolan_python-0.1.5 → portolan_python-0.1.6}/docs/distribution.md +4 -4
- {portolan_python-0.1.5 → portolan_python-0.1.6}/docs/examples.md +2 -2
- {portolan_python-0.1.5 → portolan_python-0.1.6}/pyproject.toml +1 -1
- {portolan_python-0.1.5 → portolan_python-0.1.6}/src/portolan/registry.py +17 -6
- {portolan_python-0.1.5 → portolan_python-0.1.6}/tests/test_registry_api.py +72 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/uv.lock +1 -1
- {portolan_python-0.1.5 → portolan_python-0.1.6}/.github/workflows/release.yml +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/.gitignore +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/Makefile +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/README.md +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/docs/development.md +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/docs/scope.md +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/src/portolan/__init__.py +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/src/portolan/catalog.py +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/src/portolan/py.typed +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/src/portolan/validation.py +0 -0
- {portolan_python-0.1.5 → portolan_python-0.1.6}/tests/test_catalog_api.py +0 -0
|
Binary file
|
|
@@ -8,8 +8,8 @@ preferred package index for published versions.
|
|
|
8
8
|
Push a tag that matches the version in `pyproject.toml`:
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
git tag v0.1.
|
|
12
|
-
git push origin v0.1.
|
|
11
|
+
git tag v0.1.6
|
|
12
|
+
git push origin v0.1.6
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
The release workflow runs the tests, builds both distributions, checks their
|
|
@@ -25,7 +25,7 @@ Install the wheel attached to a release:
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
python -m pip install \
|
|
28
|
-
https://github.com/jemacchi/portolan-python/releases/download/v0.1.
|
|
28
|
+
https://github.com/jemacchi/portolan-python/releases/download/v0.1.6/portolan_python-0.1.6-py3-none-any.whl
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
This path needs no package index account.
|
|
@@ -35,7 +35,7 @@ This path needs no package index account.
|
|
|
35
35
|
Install a published version from PyPI with:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
python -m pip install portolan-python==0.1.
|
|
38
|
+
python -m pip install portolan-python==0.1.6
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Omit the version constraint to install the latest published version.
|
|
@@ -10,14 +10,14 @@ GitHub:
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
python -m pip install \
|
|
13
|
-
https://github.com/jemacchi/portolan-python/releases/download/v0.1.
|
|
13
|
+
https://github.com/jemacchi/portolan-python/releases/download/v0.1.6/portolan_python-0.1.6-py3-none-any.whl
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
You can also install the source at a specific tag:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
python -m pip install \
|
|
20
|
-
"portolan-python @ git+https://github.com/jemacchi/portolan-python.git@v0.1.
|
|
20
|
+
"portolan-python @ git+https://github.com/jemacchi/portolan-python.git@v0.1.6"
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## List collections and assets
|
|
@@ -221,16 +221,27 @@ def _write_catalog_tree(
|
|
|
221
221
|
rewritten_links: list[Any] = []
|
|
222
222
|
for link in links:
|
|
223
223
|
rewritten_link = link
|
|
224
|
-
if isinstance(link, dict) and link.get("
|
|
225
|
-
href = link
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
if isinstance(link, dict) and isinstance(link.get("href"), str):
|
|
225
|
+
href = link["href"]
|
|
226
|
+
linked_url = urljoin(document_url, href)
|
|
227
|
+
rewritten_link = {**link, "href": linked_url}
|
|
228
|
+
if link.get("rel") in {"root", "parent"}:
|
|
229
|
+
linked_target = next(
|
|
230
|
+
(path for path, owner_url in targets.items() if owner_url == linked_url),
|
|
231
|
+
None,
|
|
232
|
+
)
|
|
233
|
+
if linked_target is not None:
|
|
234
|
+
rewritten_link = {
|
|
235
|
+
**link,
|
|
236
|
+
"href": _relative_local_href(target, linked_target),
|
|
237
|
+
}
|
|
238
|
+
if link.get("rel") == "child":
|
|
239
|
+
child_url = linked_url
|
|
228
240
|
child_target = _target_document_path(root_url, child_url, output_root)
|
|
229
241
|
owner = targets.get(child_target)
|
|
230
242
|
if owner is not None and owner != child_url:
|
|
231
243
|
raise ValueError(
|
|
232
|
-
"Registry documents map to the same local path: "
|
|
233
|
-
f"{owner}, {child_url}"
|
|
244
|
+
f"Registry documents map to the same local path: {owner}, {child_url}"
|
|
234
245
|
)
|
|
235
246
|
if child_url in visited:
|
|
236
247
|
if owner == child_url:
|
|
@@ -234,6 +234,78 @@ def test_download_registry_catalog_rewrites_downloaded_children_to_local_hrefs(
|
|
|
234
234
|
assert collection["links"] == [{"rel": "child", "href": "../catalog.json"}]
|
|
235
235
|
|
|
236
236
|
|
|
237
|
+
def test_download_registry_catalog_makes_non_downloaded_relative_links_absolute(
|
|
238
|
+
tmp_path: Path,
|
|
239
|
+
) -> None:
|
|
240
|
+
root_url = "https://example.test/demo/catalog.json"
|
|
241
|
+
collection_url = "https://example.test/demo/roads/collection.json"
|
|
242
|
+
feature_url = "https://example.test/demo/roads/features/road-1.json"
|
|
243
|
+
responses = {
|
|
244
|
+
root_url: {
|
|
245
|
+
"type": "Catalog",
|
|
246
|
+
"id": "demo",
|
|
247
|
+
"links": [{"rel": "child", "href": "./roads/collection.json"}],
|
|
248
|
+
},
|
|
249
|
+
collection_url: {
|
|
250
|
+
**_collection("roads", {}),
|
|
251
|
+
"links": [
|
|
252
|
+
{"rel": "item", "href": "./items/road-1.json"},
|
|
253
|
+
{"rel": "child", "href": "./features/road-1.json"},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
feature_url: {"type": "Feature", "id": "road-1"},
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
catalog_root = download_registry_catalog(
|
|
260
|
+
root_url,
|
|
261
|
+
tmp_path,
|
|
262
|
+
fetch_json=lambda url: responses[url],
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
collection = json.loads(
|
|
266
|
+
(catalog_root / "roads" / "collection.json").read_text(encoding="utf-8")
|
|
267
|
+
)
|
|
268
|
+
assert collection["links"] == [
|
|
269
|
+
{"rel": "item", "href": "https://example.test/demo/roads/items/road-1.json"},
|
|
270
|
+
{"rel": "child", "href": feature_url},
|
|
271
|
+
]
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def test_download_registry_catalog_keeps_downloaded_root_and_parent_links_local(
|
|
275
|
+
tmp_path: Path,
|
|
276
|
+
) -> None:
|
|
277
|
+
root_url = "https://example.test/demo/catalog.json"
|
|
278
|
+
collection_url = "https://example.test/demo/roads/collection.json"
|
|
279
|
+
responses = {
|
|
280
|
+
root_url: {
|
|
281
|
+
"type": "Catalog",
|
|
282
|
+
"id": "demo",
|
|
283
|
+
"links": [{"rel": "child", "href": "./roads/collection.json"}],
|
|
284
|
+
},
|
|
285
|
+
collection_url: {
|
|
286
|
+
**_collection("roads", {}),
|
|
287
|
+
"links": [
|
|
288
|
+
{"rel": "root", "href": root_url},
|
|
289
|
+
{"rel": "parent", "href": root_url},
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
catalog_root = download_registry_catalog(
|
|
295
|
+
root_url,
|
|
296
|
+
tmp_path,
|
|
297
|
+
fetch_json=lambda url: responses[url],
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
collection = json.loads(
|
|
301
|
+
(catalog_root / "roads" / "collection.json").read_text(encoding="utf-8")
|
|
302
|
+
)
|
|
303
|
+
assert collection["links"] == [
|
|
304
|
+
{"rel": "root", "href": "../catalog.json"},
|
|
305
|
+
{"rel": "parent", "href": "../catalog.json"},
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
|
|
237
309
|
def test_download_registry_catalog_skips_child_cycles(tmp_path: Path) -> None:
|
|
238
310
|
root_url = "https://example.test/demo/catalog.json"
|
|
239
311
|
child_url = "https://example.test/demo/roads/collection.json"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|