diff options
author | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2020-12-31 18:00:05 +0100 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2020-12-31 18:38:49 +0100 |
commit | 818680c71d2a407f76ae9dc9edaee6c8b338ab2c (patch) | |
tree | 3a2d5e76c8ad1e0fddad54a644d4a0fd54f2fb69 | |
parent | 08984781ec38f9ba8b35c70c6a5fff38e00b55aa (diff) | |
download | python-setuptools-git-818680c71d2a407f76ae9dc9edaee6c8b338ab2c.tar.gz |
Simplify `setuptools.glob._iglob`
-rw-r--r-- | setuptools/glob.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/setuptools/glob.py b/setuptools/glob.py index 9d7cbc5d..87062b81 100644 --- a/setuptools/glob.py +++ b/setuptools/glob.py @@ -47,6 +47,8 @@ def iglob(pathname, recursive=False): def _iglob(pathname, recursive): dirname, basename = os.path.split(pathname) + glob_in_dir = glob2 if recursive and _isrecursive(basename) else glob1 + if not has_magic(pathname): if basename: if os.path.lexists(pathname): @@ -56,13 +58,9 @@ def _iglob(pathname, recursive): if os.path.isdir(dirname): yield pathname return + if not dirname: - if recursive and _isrecursive(basename): - for x in glob2(dirname, basename): - yield x - else: - for x in glob1(dirname, basename): - yield x + yield from glob_in_dir(dirname, basename) return # `os.path.split()` returns the argument itself as a dirname if it is a # drive or UNC path. Prevent an infinite recursion if a drive or UNC path @@ -71,12 +69,7 @@ def _iglob(pathname, recursive): dirs = _iglob(dirname, recursive) else: dirs = [dirname] - if has_magic(basename): - if recursive and _isrecursive(basename): - glob_in_dir = glob2 - else: - glob_in_dir = glob1 - else: + if not has_magic(basename): glob_in_dir = glob0 for dirname in dirs: for name in glob_in_dir(dirname, basename): |