diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e430b04..81dcdabe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Harden the geojson annotation parser ([#1743](../../pull/1743)) - Add more color palettes ([#1746](../../pull/1746)) +- Improve the list of extensions the bioformats source reports ([#1748](../../pull/1748)) ## 1.30.5 diff --git a/sources/bioformats/large_image_source_bioformats/__init__.py b/sources/bioformats/large_image_source_bioformats/__init__.py index 6b092ba29..6c1a1b79e 100644 --- a/sources/bioformats/large_image_source_bioformats/__init__.py +++ b/sources/bioformats/large_image_source_bioformats/__init__.py @@ -741,6 +741,19 @@ def addKnownExtensions(cls): ext = dotext.strip('.') if ext not in cls.extensions: cls.extensions[ext] = SourcePriority.IMPLICIT + # The python modules doesn't list all the extensions that can be + # read, so supplement from the jar + readerlist = zipfile.ZipFile( + pathlib.Path(bioformats.__file__).parent / + 'jars/bioformats_package.jar', + ).open('loci/formats/readers.txt').read(100000).decode().split('\n') + pattern = re.compile(r'^loci\.formats\.in\..* # (?:.*?\b(\w{2,})\b(?:,|\s|$))') + for line in readerlist: + for ext in set(pattern.findall(line)) - { + 'pattern', 'urlreader', 'screen', 'zip', 'zarr', 'db', + 'fake', 'no'}: + if ext not in cls.extensions: + cls.extensions[ext] = SourcePriority.IMPLICIT def open(*args, **kwargs):