Resolve "CLI in-place import impossible with virtualenv with python3.5"

This commit is contained in:
Agate 2020-06-05 10:42:56 +02:00
parent 96f6b1e192
commit f54038ca83
4 changed files with 20 additions and 1 deletions

View file

@ -27,7 +27,8 @@ def crawl_dir(dir, extensions, recursive=True, ignored=[]):
if os.path.isfile(dir):
yield dir
return
with os.scandir(dir) as scanner:
try:
scanner = os.scandir(dir)
for entry in scanner:
if entry.is_file():
for e in extensions:
@ -38,6 +39,9 @@ def crawl_dir(dir, extensions, recursive=True, ignored=[]):
yield from crawl_dir(
entry, extensions, recursive=recursive, ignored=ignored
)
finally:
if hasattr(scanner, "close"):
scanner.close()
def batch(iterable, n=1):