addon-sdk/source/python-lib/cuddlefish/util.py
author Phil Ringnalda <philringnalda@gmail.com>
Tue, 19 Nov 2013 14:38:29 -0800
changeset 171124 78fb435aa0d2a1130271ae2016c3c98042c1d887
parent 130502 a874d2756f6530a8ee7c8dc6dbcb7102944d5127
permissions -rw-r--r--
Backed out 4 changesets (bug 672843) for xpcshell bustage Backed out changeset bbb7760083ae (bug 672843) Backed out changeset eaf2fd75d7fc (bug 672843) Backed out changeset eb08cc206b8d (bug 672843) Backed out changeset 6a0e4afd52ab (bug 672843)

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


IGNORED_FILE_PREFIXES = ["."]
IGNORED_FILE_SUFFIXES = ["~", ".swp"]
IGNORED_DIRS = [".git", ".svn", ".hg"]

def filter_filenames(filenames, ignored_files=[".hgignore"]):
    for filename in filenames:
        if filename in ignored_files:
            continue
        if any([filename.startswith(suffix)
                for suffix in IGNORED_FILE_PREFIXES]):
            continue
        if any([filename.endswith(suffix)
                for suffix in IGNORED_FILE_SUFFIXES]):
            continue
        yield filename

def filter_dirnames(dirnames):
    return [dirname for dirname in dirnames if dirname not in IGNORED_DIRS]