Skip to content

Commit

Permalink
Merge pull request #1748 from girder/bioformats-extensions
Browse files Browse the repository at this point in the history
Improve the list of extensions the bioformats source reports
  • Loading branch information
manthey authored Dec 30, 2024
2 parents 20c5cc9 + d1f0428 commit 64afb30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions sources/bioformats/large_image_source_bioformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 64afb30

Please sign in to comment.