addon-sdk/source/python-lib/cuddlefish/util.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/python-lib/cuddlefish/util.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +
     1.9 +IGNORED_FILE_PREFIXES = ["."]
    1.10 +IGNORED_FILE_SUFFIXES = ["~", ".swp"]
    1.11 +IGNORED_DIRS = [".git", ".svn", ".hg"]
    1.12 +
    1.13 +def filter_filenames(filenames, ignored_files=[".hgignore"]):
    1.14 +    for filename in filenames:
    1.15 +        if filename in ignored_files:
    1.16 +            continue
    1.17 +        if any([filename.startswith(suffix)
    1.18 +                for suffix in IGNORED_FILE_PREFIXES]):
    1.19 +            continue
    1.20 +        if any([filename.endswith(suffix)
    1.21 +                for suffix in IGNORED_FILE_SUFFIXES]):
    1.22 +            continue
    1.23 +        yield filename
    1.24 +
    1.25 +def filter_dirnames(dirnames):
    1.26 +    return [dirname for dirname in dirnames if dirname not in IGNORED_DIRS]

mercurial