Skip to content

Commit d848f50

Browse files
committed
cleaned up code
1 parent c2f652e commit d848f50

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

xcube/core/store/fs/store.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_data_types(cls) -> tuple[str, ...]:
221221

222222
def get_data_types_for_data(self, data_id: str) -> tuple[str, ...]:
223223
self._assert_valid_data_id(data_id)
224-
all_opener_id_parts = self._guess_all_opener_id_parts(data_id)
224+
all_opener_id_parts = self._guess_all_opener_id_parts(data_id, require=False)
225225
data_type_aliases = [dta for dta, format_id, protocol in all_opener_id_parts]
226226
return tuple(data_type_aliases)
227227

@@ -251,7 +251,6 @@ def describe_data(
251251
self, data_id: str, data_type: DataTypeLike = None
252252
) -> DataDescriptor:
253253
self._assert_valid_data_id(data_id)
254-
self._assert_data_specified(data_id, data_type)
255254
# TODO: optimize me, self.open_data() may be very slow!
256255
# For Zarr, try using self.fs to load metadata only
257256
# rather than instantiating xr.Dataset instances which
@@ -284,8 +283,6 @@ def get_data_opener_ids(
284283
)
285284
return results
286285
storage_id = self.protocol
287-
if data_type == ANY_TYPE:
288-
data_type = None
289286
return tuple(
290287
ext.name
291288
for ext in find_data_opener_extensions(
@@ -545,17 +542,6 @@ def _find_writer(
545542
return None
546543
return new_data_writer(writer_id)
547544

548-
def _is_data_specified(
549-
self, data_id: str, data_type: DataTypeLike, require: bool = False
550-
) -> bool:
551-
if not self._is_data_type_available(data_id, data_type):
552-
if require:
553-
raise DataStoreError(
554-
f"Cannot determine data type of resource {data_id!r}"
555-
)
556-
return False
557-
return True
558-
559545
def _is_data_type_available(self, data_id: str, data_type: DataTypeLike) -> bool:
560546
ext = self._get_filename_ext(data_id)
561547
format_id = self._get_filename_ext_to_format_openers().get(ext.lower())
@@ -568,9 +554,6 @@ def _is_data_type_available(self, data_id: str, data_type: DataTypeLike) -> bool
568554
for avail_data_type in avail_data_types
569555
)
570556

571-
def _assert_data_specified(self, data_id, data_type: DataTypeLike):
572-
self._is_data_specified(data_id, data_type, require=True)
573-
574557
def _ensure_valid_data_id(self, writer_id: str, data_id: str = None) -> str:
575558
format_id = writer_id.split(":")[1]
576559
first_ext = None
@@ -786,7 +769,7 @@ def _generate_data_ids(
786769
file_path = file_path[len(self.root) + 2 :]
787770
if not file_path:
788771
continue
789-
if self._is_data_specified(file_path, data_type):
772+
if self._is_data_type_available(file_path, data_type):
790773
yield (file_path, {}) if return_tuples else file_path
791774
elif file_info.get("type") == "directory" and (
792775
self._max_depth is None or current_depth < self._max_depth

0 commit comments

Comments
 (0)