wsutil/wsgcrypt.c decrypt_des_ecb
[wireshark-sm.git] / tools / pre-commit-ignore.py
blobd06990344f8c3766ca64e4d2cf2646ec1d0987f5
1 #!/bin/env python3
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
9 import sys
10 import fnmatch
12 IGNORE_CONF = "pre-commit-ignore.conf"
14 if len(sys.argv) > 2:
15 print("Usage: {0} [path/to/ignore.conf]".format(sys.argv[0]))
16 sys.exit(1)
18 if len(sys.argv) == 2:
19 ignore_path = sys.argv[1]
20 else:
21 ignore_path = IGNORE_CONF
23 # Function to load our patterns from 'path' for modified files
24 # to be ignored (skipping any comments)
25 def load_checkignore(path):
26 try:
27 with open(path) as f:
28 patterns = f.read()
29 except OSError as err:
30 sys.exit(str(err))
31 ign = [line.strip() for line in patterns.splitlines()]
32 ign = [line for line in ign if line and not line.startswith("#")]
33 return ign
35 ignore_list = load_checkignore(ignore_path)
37 def ignore_match(f):
38 for p in ignore_list:
39 if fnmatch.fnmatchcase(f, p):
40 return True
41 return False
43 for line in sys.stdin:
44 line = line.strip()
45 if not ignore_match(line):
46 print(line)
49 # Editor modelines
51 # Local Variables:
52 # c-basic-offset: 4
53 # indent-tabs-mode: nil
54 # End:
56 # ex: set shiftwidth=4 expandtab:
57 # :indentSize=4:noTabs=true: