Faster walk by excluding some directories
This commit is contained in:
parent
133c83ed8e
commit
11ed593880
1 changed files with 7 additions and 0 deletions
|
|
@ -4,7 +4,14 @@ import sys
|
||||||
|
|
||||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
|
root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
|
||||||
verbose = '-v' in sys.argv
|
verbose = '-v' in sys.argv
|
||||||
|
excludes = ('.git', '.svn', '__pycache__')
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(root):
|
for dirpath, dirnames, filenames in os.walk(root):
|
||||||
|
for exclude in excludes:
|
||||||
|
try:
|
||||||
|
dirnames.remove(exclude)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if filename.endswith('.pyc') or filename.endswith('pyo'):
|
if filename.endswith('.pyc') or filename.endswith('pyo'):
|
||||||
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
|
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue