From 474a9ffca348f082d356c703a22565216d55d575 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Sun, 6 Jan 2019 18:33:35 -0500 Subject: [PATCH 1/2] Ensure `open` handles `list`s correctly The call to `glob` was causing `list`s of files to fail in `open`. This fixes that issue by looping over the `list`s contents, calling `glob` on each one, and concatenating them into a list of files. --- pims/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pims/api.py b/pims/api.py index 0da4792a..8fd73983 100644 --- a/pims/api.py +++ b/pims/api.py @@ -162,7 +162,13 @@ def open(sequence, **kwargs): >>> frame_count = len(video) # Number of frames in video >>> frame_shape = video.frame_shape # Pixel dimensions of video """ - files = glob.glob(sequence) + if not isinstance(sequence, list): + sequence = [sequence] + + files = [] + for each_seq in sequence: + files.extend(glob.glob(each_seq)) + if len(files) > 1: # todo: test if ImageSequence can read the image type, # delegate to subclasses as needed From 7141a751eab8244aa5c1500bc68669ce2e1ec737 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Sun, 6 Jan 2019 18:44:19 -0500 Subject: [PATCH 2/2] Prefer `files` to `sequence` in later arguments --- pims/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pims/api.py b/pims/api.py index 8fd73983..c08cf216 100644 --- a/pims/api.py +++ b/pims/api.py @@ -172,9 +172,9 @@ def open(sequence, **kwargs): if len(files) > 1: # todo: test if ImageSequence can read the image type, # delegate to subclasses as needed - return ImageSequence(sequence, **kwargs) + return ImageSequence(files, **kwargs) - _, ext = os.path.splitext(sequence) + _, ext = os.path.splitext(files[0]) if ext is None or len(ext) < 2: raise UnknownFormatError( "Could not detect your file type because it did not have an " @@ -207,7 +207,7 @@ def priority(cls): exceptions = '' for handler in sort_on_priority(eligible_handlers): try: - return handler(sequence, **kwargs) + return handler(files[0], **kwargs) except Exception as e: message = '{0} errored: {1}'.format(str(handler), str(e)) warn(message)