Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract get_all_handlers into function #427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pims/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def __init__(self, *args, **kwargs):
except ImportError:
ND2Reader = not_available("nd2reader")

def get_all_handlers():
# list all readers derived from the pims baseclasses
return chain(_recursive_subclasses(FramesSequence),
_recursive_subclasses(FramesSequenceND))

def open(sequence, **kwargs):
"""Read a filename, list of filenames, or directory of image files into an
iterable that returns images as numpy arrays.
Expand Down Expand Up @@ -173,9 +178,8 @@ def open(sequence, **kwargs):
"Video({0})".format(sequence))
ext = ext.lower()[1:]

# list all readers derived from the pims baseclasses
all_handlers = chain(_recursive_subclasses(FramesSequence),
_recursive_subclasses(FramesSequenceND))
all_handlers = get_all_handlers()

# keep handlers that support the file ext. use set to avoid duplicates.
eligible_handlers = set(h for h in all_handlers
if ext and ext in map(_drop_dot, h.class_exts()))
Expand Down