From cdf551f28a4b29c5357e2b131b6b72593933bd0f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 11 Aug 2021 01:01:02 -0700 Subject: [PATCH] Let glob_filenames, glob_directories be singular strings. --- voussoirkit/spinal.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index d428909..7fdc958 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -793,7 +793,8 @@ def walk( glob_directories: A set of glob patterns. Directories will only be yielded if they match - at least one of these patterns. + at least one of these patterns. Directories which do not match these + patterns will still be used for traversal, though. glob_filenames: A set of glob patterns. Filenames will only be yielded if they match @@ -829,10 +830,18 @@ def walk( if exclude_directories is not None: exclude_directories = {normalize(f) for f in exclude_directories} - if glob_filenames is not None: + if glob_filenames is None: + pass + elif isinstance(glob_filenames, str): + glob_filenames = {glob_filenames} + else: glob_filenames = set(glob_filenames) - if glob_directories is not None: + if glob_directories is None: + pass + elif isinstance(glob_directories, str): + glob_directories = {glob_directories} + else: glob_directories = set(glob_directories) path = pathclass.Path(path)