From ae88a1d56df19b8e1cd5f8be9bc73e195e256c31 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Wed, 7 Dec 2022 11:35:15 -0500 Subject: [PATCH] s1_reader: fix safe_path for directories (#91) * s1_reader: fix safe_path for directories _burst_from_safe_dir used os.listdir, which does not have "measurement" in the returned names like the zip file list does this fixes #90 * return a string instead of list --- src/s1reader/s1_reader.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/s1reader/s1_reader.py b/src/s1reader/s1_reader.py index 8e98de0d..b128dcfe 100644 --- a/src/s1reader/s1_reader.py +++ b/src/s1reader/s1_reader.py @@ -876,10 +876,8 @@ def _burst_from_safe_dir(safe_dir_path: str, id_str: str, orbit_path: str, flag_ # find tiff file if measurement directory found if os.path.isdir(f'{safe_dir_path}/measurement'): - measurement_list = os.listdir(f'{safe_dir_path}/measurement') - f_tiff = [f for f in measurement_list - if 'measurement' in f and id_str in f and 'tiff' in f] - f_tiff = f'{safe_dir_path}/measurement/{f_tiff[0]}' if f_tiff else '' + f_tiff = glob.glob(f'{safe_dir_path}/measurement/*{id_str}*tiff') + f_tiff = f_tiff[0] if f_tiff else '' else: msg = f'measurement directory NOT found in {safe_dir_path}' msg += ', continue with metadata only.'