Created
April 5, 2012 02:45
-
-
Save keitaoouchi/2307608 to your computer and use it in GitHub Desktop.
Recursive directory listing with ignore pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def recursive_listing(root, ignoredirs=None, ignorefiles=None): | |
result = [] | |
ignoredirs = ignoredirs or [] | |
ignorefiles = ignorefiles or [] | |
for dir, subdirs, fnames in os.walk(root): | |
if all(map(lambda d: d not in dir, ignoredirs)): | |
for name in fnames: | |
if all(map(lambda f: f not in name, ignorefiles)): | |
result.append("{0}/{1}".format(dir, name)) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment