Verify whether the specified file or files format match supported suffixes. If supported suffixes is None, skip the verification and return True. Args: filename: file name or a list of file names to read. if a list of files, verify all the suffixes. suffixes
(filename: Sequence[PathLike] | PathLike, suffixes: Sequence[str])
| 1110 | |
| 1111 | |
| 1112 | def is_supported_format(filename: Sequence[PathLike] | PathLike, suffixes: Sequence[str]) -> bool: |
| 1113 | """ |
| 1114 | Verify whether the specified file or files format match supported suffixes. |
| 1115 | If supported suffixes is None, skip the verification and return True. |
| 1116 | |
| 1117 | Args: |
| 1118 | filename: file name or a list of file names to read. |
| 1119 | if a list of files, verify all the suffixes. |
| 1120 | suffixes: all the supported image suffixes of current reader, must be a list of lower case suffixes. |
| 1121 | |
| 1122 | """ |
| 1123 | filenames: Sequence[PathLike] = ensure_tuple(filename) |
| 1124 | for name in filenames: |
| 1125 | full_suffix = "".join(map(str.lower, PurePath(name).suffixes)) |
| 1126 | if all(f".{s.lower()}" not in full_suffix for s in suffixes): |
| 1127 | return False |
| 1128 | |
| 1129 | return True |
| 1130 | |
| 1131 | |
| 1132 | def partition_dataset( |
searching dependent graphs…