Skip to content

Commit 3b3c28c

Browse files
refining
1 parent 138a10c commit 3b3c28c

3 files changed

Lines changed: 15 additions & 34 deletions

File tree

databusclient/api/queries.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,24 @@ def parse_content_variants_string(variants_str: str) -> dict:
5858
Parameters
5959
----------
6060
variants_str : str
61-
Comma-separated string of content variants, e.g., "lang=en, type=full, sorted=true"
61+
Comma-separated string of content variants, e.g., "lang=en, type=full, sorted"
6262
6363
Returns
6464
-------
6565
dict
66-
Dictionary of key-value pairs, e.g., {"lang": "en", "type": "full", "sorted": "true"}
66+
Dictionary of parsed content variants. For key=value pairs, both the key
67+
and value are returned as strings (no type conversion is performed, so
68+
"true" remains the string "true", not a boolean). For standalone values
69+
without an "=" sign, the value is recorded as the boolean ``True``.
70+
71+
Example: "lang=en, type=full, sorted" -> {"lang": "en", "type": "full", "sorted": True}
72+
73+
Notes
74+
-----
75+
- All values from key=value pairs are kept as strings. If you need boolean
76+
or numeric conversion, perform it after calling this function.
77+
- Standalone items (e.g., "sorted") are stored with boolean ``True`` as
78+
their value, indicating presence rather than a specific string value.
6779
"""
6880
if not variants_str or variants_str.strip() == "":
6981
return {}

databusclient/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
import json
33
import os
4-
import re
54
from typing import List
65

76
import click

tests/test_deploy.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,9 @@
1111
_get_content_variants,
1212
BadArgumentException,
1313
)
14-
from databusclient.cli import parse_distribution_str
15-
16-
EXAMPLE_URL = "https://raw.githubusercontent.com/dbpedia/databus/608482875276ef5df00f2360a2f81005e62b58bd/server/app/api/swagger.yml"
1714

1815

19-
def test_parse_distribution_str():
20-
"""Test the new pipe-separated distribution string parser"""
21-
22-
# Test with multiple content variants
23-
result = parse_distribution_str("http://example.com/data|lang=en|type=full|sorted=true|.ttl|.gz")
24-
assert result["url"] == "http://example.com/data"
25-
assert result["variants"] == {"lang": "en", "type": "full", "sorted": "true"}
26-
assert result["formatExtension"] == "ttl"
27-
assert result["compression"] == "gz"
28-
29-
# Test with single content variant
30-
result = parse_distribution_str("http://mysite.com/data.json|lang=fr|.json")
31-
assert result["url"] == "http://mysite.com/data.json"
32-
assert result["variants"] == {"lang": "fr"}
33-
assert result["formatExtension"] == "json"
34-
assert result["compression"] is None
35-
36-
# Test URL only
37-
result = parse_distribution_str("http://example.com/file.csv")
38-
assert result["url"] == "http://example.com/file.csv"
39-
assert result["variants"] == {}
40-
assert result["formatExtension"] is None
41-
assert result["compression"] is None
42-
43-
# Test with compression only (no format extension)
44-
result = parse_distribution_str("http://example.com/data|.gz")
45-
assert result["url"] == "http://example.com/data"
46-
assert result["compression"] == "gz"
16+
EXAMPLE_URL = "https://raw.githubusercontent.com/dbpedia/databus/608482875276ef5df00f2360a2f81005e62b58bd/server/app/api/swagger.yml"
4717

4818

4919
def test_get_content_variants():

0 commit comments

Comments
 (0)