nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/bin/env python
2 #
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  
21 import sys
22 import os
23 import fnmatch
24  
25 IGNORE_CONF = "pre-commit-ignore.conf"
26  
27 if len(sys.argv) > 2:
28 print("Usage: {0} [path/to/ignore.conf]".format(sys.argv[0]))
29 sys.exit(1)
30  
31 if len(sys.argv) == 2:
32 ignore_path = sys.argv[1]
33 else:
34 ignore_path = IGNORE_CONF
35  
36 # Function to load our patterns from 'path' for modified files
37 # to be ignored (skipping any comments)
38 def load_checkignore(path):
39 try:
40 with open(path) as f:
41 patterns = f.read()
42 except OSError as err:
43 print(str(err))
44 return []
45 ign = [l.strip() for l in patterns.splitlines()]
46 ign = [l for l in ign if l and not l.startswith("#")]
47 return ign
48  
49 ignore_list = load_checkignore(ignore_path)
50  
51 def ignore_match(f):
52 for p in ignore_list:
53 if fnmatch.fnmatchcase(f, p):
54 return True
55 return False
56  
57 for line in sys.stdin:
58 line = line.strip()
59 if not ignore_match(line):
60 print(line)
61  
62 #
63 # Editor modelines
64 #
65 # Local Variables:
66 # c-basic-offset: 4
67 # indent-tabs-mode: nil
68 # End:
69 #
70 # ex: set shiftwidth=4 expandtab:
71 # :indentSize=4:noTabs=true:
72 #