I'm processing a list of files, and want to check the filenames against a list of regex, like:
IGNORE_FILES = [
re.compile('^./Vendor.*'),
re.compile('^./Pods.*'),
…
]
def in_blacklist(file):
return len(list(filter(lambda r: r.match(file) != None, IGNORE_FILES))) > 0
def in_whitelist(file):
return SWIFT_FILE_REGEX.match(file) != None
def files():
valid_files = []
for root, dirs, files in os.walk('.'):
for file in files:
if in_whitelist(file) and not in_blacklist(root):
valid_files.append("%s/%s" % (root, file))
return valid_files
I'm looking for a smoother way to write:
len(list(filter(lambda r: r.match(root) != None, IGNORE_FILES))) == 0
I feel that it's not so easy to read, and especially with the list(..)