Skip to content

Conversation

XavierJiezou
Copy link

This PR enhances the file search functionality to include subdirectories by using glob.glob with the recursive=True parameter. This change ensures that all image files within the specified directory and its subdirectories are found, improving the flexibility and robustness of the file search.

Fixed issue

  • Replaced pathlib.Path.glob with glob.glob to enable recursive search.
  • Ensured compatibility with existing code by maintaining the use of standard libraries.

Details

# Before
files = sorted(
    [file for ext in IMAGE_EXTENSIONS for file in path.glob("*.{}".format(ext))]
)

# After
import glob

files = sorted([file for ext in IMAGE_EXTENSIONS for file in glob.glob(os.path.join(path, '**/*.{}'.format(ext)), recursive=True)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant