Skip to content

Commit dd361b5

Browse files
committed
Use recursive glob() available in Python 3.5+
1 parent 119bd82 commit dd361b5

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,19 @@ def run():
7878
rmtree_glob(candidate)
7979
for visible_dir in glob('[A-Za-z0-9_]*'):
8080
for candidate in delete_everywhere:
81-
rmtree_glob(os.path.join(visible_dir, candidate))
82-
rmtree_glob(os.path.join(visible_dir, '*', candidate))
83-
rmtree_glob(os.path.join(visible_dir, '*', '*', candidate))
81+
rmtree_glob(os.path.join(visible_dir, '**', candidate))
8482

8583

8684
def rmtree_glob(file_glob):
8785
"""Platform independent rmtree, which also allows wildcards (globbing)"""
88-
for item in glob(file_glob):
86+
for item in glob(file_glob, recursive=True):
8987
try:
90-
shutil.rmtree(item)
91-
print('%s/ removed ...' % item)
88+
os.remove(item)
89+
print('%s removed ...' % item)
9290
except OSError:
9391
try:
94-
os.remove(item)
95-
print('%s removed ...' % item)
92+
shutil.rmtree(item)
93+
print('%s/ removed ...' % item)
9694
except OSError as err:
9795
print(err)
9896

0 commit comments

Comments
 (0)