forked from gluster/glusterfs-patch-acceptance-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
is-ignored-file.py
executable file
·30 lines (25 loc) · 941 Bytes
/
is-ignored-file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
import argparse
import os.path
from fnmatch import fnmatch
import sys
def pattern_test(path, pattern):
if fnmatch(path, pattern.strip()):
sys.exit(0)
parser = argparse.ArgumentParser(description='Check if the file is ignored')
parser.add_argument('path', metavar='PATH', type=unicode,
help='The path to the file to test')
parser.add_argument('--ignore-file', default='.testignore',
metavar='IGNORE_FILE',
help='Path to the .testignore file')
args = parser.parse_args()
if not os.path.isfile(args.ignore_file):
# This means we're working on an older branch without the .testignore file
patterns = ['doc/*', 'build-aux/*']
for pattern in patterns:
pattern_test(args.path, pattern.strip())
else:
with open(args.ignore_file) as f:
for pattern in f:
pattern_test(args.path, pattern.strip())
sys.exit(1)