Skip to content

Commit 1e94bc1

Browse files
committed
search ucase file extensions if not running on Windows.
Signed-off-by: Jonathan Walker <[email protected]>
1 parent 57a03fa commit 1e94bc1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

swat/cas/datamsghandlers.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626

2727
import base64
2828
import copy
29+
import datetime
2930
import io
3031
import os
3132
import re
32-
import datetime
33+
import sys
3334
import warnings
3435
import numpy as np
3536
import pandas as pd
@@ -1236,21 +1237,23 @@ class Image(CASDataMsgHandler):
12361237
... CASTable('MYTABLE', caslib='CASUSER(user)')
12371238
12381239
"""
1239-
12401240
def __init__(self, data, nrecs=1000, subdirs=True):
1241-
12421241
# To maintain Py2.7 compatibility, use strings instead of Paths.
12431242
if type(data).__module__ == 'pathlib':
12441243
data = str(data)
12451244

12461245
if isinstance(data, str):
12471246
files = []
1247+
extensions = ['bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jp2', 'png', 'pbm', 'pmg',
1248+
'ppm', 'tif', 'tiff', 'webp']
12481249

1249-
# Search for all images in the directory and (optionally) in subdirectories
1250-
for extension in (
1251-
'bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jp2', 'png', 'pbm', 'pmg', 'ppm',
1252-
'tif', 'tiff', 'webp'):
1250+
# Also search for uppercase file extensions if not running on a
1251+
# case-insensitive OS (Windows).
1252+
if not sys.platform.startswith('win'):
1253+
extensions += [x.upper() for x in extensions]
12531254

1255+
# Search for all images in the directory and (optionally) in subdirectories
1256+
for extension in extensions:
12541257
if subdirs:
12551258
pattern = os.path.join(data, '**', '*.%s' % extension)
12561259
else:

0 commit comments

Comments
 (0)