Skip to content

Commit

Permalink
Simplify files property
Browse files Browse the repository at this point in the history
  • Loading branch information
adriantre committed Aug 28, 2024
1 parent 0ad5db2 commit 87ea802
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,13 @@ def files(self) -> list[Path]:
files: set[Path] = set()
for path in paths:
file_not_found = True
if os.path.isfile(path):
if fnmatch.fnmatch(str(path), os.path.join('*', self.filename_glob)):
files.add(path)
file_not_found = False
if os.path.isfile(path) and fnmatch.fnmatch(
str(path), os.path.join('*', self.filename_glob)
):
files.add(path)
elif files_found := set(list_directory_recursive(path, self.filename_glob)):
files |= files_found
file_not_found = False

if file_not_found and not hasattr(self, 'download'):
elif file_not_found and not hasattr(self, 'download'):
warnings.warn(
f"Could not find any relevant files for provided path '{path}'. "
f'Path was ignored.',
Expand Down

0 comments on commit 87ea802

Please sign in to comment.