Skip to content

Commit

Permalink
Optimize readers searching for matching filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed May 4, 2020
1 parent a82e4a6 commit 0cbea18
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions satpy/readers/yaml_reader.py
Expand Up @@ -77,8 +77,9 @@ def match_filenames(filenames, pattern):
"""Get the filenames matching *pattern*."""
matching = []

glob_pat = globify(pattern)
for filename in filenames:
if fnmatch(get_filebase(filename, pattern), globify(pattern)):
if fnmatch(get_filebase(filename, pattern), glob_pat):
matching.append(filename)

return matching
Expand Down Expand Up @@ -184,12 +185,12 @@ def select_files_from_directory(self, directory=None):
If directory is None or '', look in the current directory.
"""
filenames = []
filenames = set()
if directory is None:
directory = ''
for pattern in self.file_patterns:
matching = glob.iglob(os.path.join(directory, globify(pattern)))
filenames.extend(matching)
filenames.update(matching)
return filenames

def select_files_from_pathnames(self, filenames):
Expand Down

0 comments on commit 0cbea18

Please sign in to comment.