michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: michael@0: IGNORED_FILE_PREFIXES = ["."] michael@0: IGNORED_FILE_SUFFIXES = ["~", ".swp"] michael@0: IGNORED_DIRS = [".git", ".svn", ".hg"] michael@0: michael@0: def filter_filenames(filenames, ignored_files=[".hgignore"]): michael@0: for filename in filenames: michael@0: if filename in ignored_files: michael@0: continue michael@0: if any([filename.startswith(suffix) michael@0: for suffix in IGNORED_FILE_PREFIXES]): michael@0: continue michael@0: if any([filename.endswith(suffix) michael@0: for suffix in IGNORED_FILE_SUFFIXES]): michael@0: continue michael@0: yield filename michael@0: michael@0: def filter_dirnames(dirnames): michael@0: return [dirname for dirname in dirnames if dirname not in IGNORED_DIRS]