Fix exclude startegy in tools/lister.py.

Previously lister.py used to check whether the exclude path is a
substring of a path being considered.  So it would fail when the
exclude path is an absolute path or uses '..' or '.'.
This commit is contained in:
Eklavya Sharma 2016-05-24 18:56:38 +05:30 committed by Tim Abbott
parent 508a080e08
commit bd63caed96
1 changed files with 5 additions and 3 deletions

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python
from __future__ import print_function
from __future__ import absolute_import
import os
from os.path import abspath
import sys
import subprocess
import re
@ -72,9 +73,10 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
for fpath in files:
# this will take a long time if exclude is very large
in_exclude = False
absfpath = abspath(fpath)
for expath in exclude:
expath = expath.rstrip('/')
if fpath == expath or fpath.startswith(expath + '/'):
expath = abspath(expath.rstrip('/'))
if absfpath == expath or absfpath.startswith(expath + '/'):
in_exclude = True
if in_exclude:
continue