Skip to content

Commit 921cb4b

Browse files
committed
allow fields[*]
1 parent ea9e5ba commit 921cb4b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

trove/render/simple_csv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def _column_paths(self) -> Iterator[Propertypath]:
8383
_expected_card_types = set(self.trove_params.cardsearch_type_iris())
8484
else:
8585
_expected_card_types = set()
86+
if '*' in self.trove_params.attrpaths_by_type:
87+
_pathlists.append(self.trove_params.attrpaths_by_type['*'])
8688
for _type_iri in sorted(_expected_card_types, key=len):
8789
try:
8890
_pathlist = self.trove_params.attrpaths_by_type[_type_iri]

trove/util/trove_params.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _gather_attrpaths(cls, queryparams: _qp.QueryparamDict, shorthand: rdf.IriSh
9999
_fields_params = queryparams.get('fields', [])
100100
if _fields_params:
101101
_requested: dict[str, list[Propertypath]] = defaultdict(list)
102+
wildcard_paths: list[Propertypath] = []
102103
for _param_name, _param_value in _fields_params:
103104
try:
104105
(_typenames,) = filter(bool, _param_name.bracketed_names)
@@ -107,13 +108,20 @@ def _gather_attrpaths(cls, queryparams: _qp.QueryparamDict, shorthand: rdf.IriSh
107108
f'expected "fields[TYPE]" (with exactly one non-empty bracketed segment)'
108109
f' (got "{_param_name}")'
109110
)
111+
if _typenames == '*':
112+
wildcard_paths.extend(
113+
parse_propertypath(_path_value, shorthand)
114+
for _path_value in _qp.split_queryparam_value(_param_value)
115+
)
110116
else:
111117
for _type in _qp.split_queryparam_value(_typenames):
112118
_type_iri = shorthand.expand_iri(_type)
113119
_requested[_type_iri].extend(
114120
parse_propertypath(_path_value, shorthand)
115121
for _path_value in _qp.split_queryparam_value(_param_value)
116122
)
123+
if wildcard_paths:
124+
_requested['*'].extend(wildcard_paths)
117125
_attrpaths = _attrpaths.with_new(freeze(_requested))
118126
return _attrpaths
119127

0 commit comments

Comments
 (0)