20
20
# SOFTWARE.
21
21
22
22
from abc import abstractmethod , ABC
23
- from typing import Iterator , Tuple , Any , Optional , List , Type
23
+ from typing import Iterator , Tuple , Any , Optional , List , Type , Sequence
24
24
25
25
from xcube .constants import EXTENSION_POINT_DATA_STORES
26
26
from xcube .util .extension import Extension
@@ -153,7 +153,10 @@ def get_type_specifiers_for_data(self, data_id: str) -> Tuple[str, ...]:
153
153
"""
154
154
155
155
@abstractmethod
156
- def get_data_ids (self , type_specifier : str = None , include_titles : bool = True ) -> \
156
+ def get_data_ids (self ,
157
+ type_specifier : str = None ,
158
+ include_titles : bool = True ,
159
+ include_attrs : Sequence [str ] = None ) -> \
157
160
Iterator [Tuple [str , Optional [str ]]]:
158
161
"""
159
162
Get an iterator over the data resource identifiers for the given type *type_specifier*.
@@ -162,13 +165,29 @@ def get_data_ids(self, type_specifier: str = None, include_titles: bool = True)
162
165
If a store implementation supports only a single data type, it should verify that *type_specifier*
163
166
is either None or compatible with the supported data type.
164
167
165
- The returned iterator items are 2-tuples of the form (*data_id*, *title*), where *data_id*
166
- is the actual data identifier and *title* is an optional, human-readable title for the data.
167
- If *include_titles* is false, the second item of the result tuple will be None.
168
+ The returned iterator items are either 2-tuples of the form (*data_id*, *title*)
169
+ or (*data_id*, *attrs*), where *data_id* is the actual data identifier:
168
170
169
- :param type_specifier: If given, only data identifiers that are available as this type are returned. If this is
170
- omitted, all available data identifiers are returned.
171
+ * The first form is returned if *include_titles* is given.
172
+ Then *title* is an optional, human-readable title (of type ``str```) for the data.
173
+ * The second form is returned if *include_attrs* is provided and not empty. and *attrs*.
174
+ Then *attrs* is a possibly empty mapping (of type ``dict```) of attribute names to values
175
+ with names given by *include_attrs*.
176
+
177
+ For data store backward compatibility, *include_titles* takes preference over *include_attrs*, so if
178
+ *include_titles* is given (the default), a store should ignore *include_attrs*.
179
+ Clients should however prefer ```include_attrs=["title", ...]``` over ```include_titles=True```.
180
+
181
+ If neither *include_titles* nor *include_attrs* is provided, the second item of the result tuple
182
+ will be None.
183
+
184
+ :param type_specifier: If given, only data identifiers that are available as this type are returned.
185
+ If this is omitted, all available data identifiers are returned.
171
186
:param include_titles: If true, the store will attempt to also provide a title.
187
+ In this case, the second tuple item is a ```str``` or None.
188
+ :param include_attrs: A sequence of names of attributes to be returned for each dataset identifier.
189
+ If given, the store will attempt to also provide the given set of dataset attributes.
190
+ In this case, the second tuple item is a ```dict``` or None. (added in 0.7.1)
172
191
:return: An iterator over the identifiers and titles of data resources provided by this data store.
173
192
:raise DataStoreError: If an error occurs.
174
193
"""
0 commit comments