]>
Commit | Line | Data |
---|---|---|
4c928ab7 MT |
1 | #!/usr/bin/python |
2 | ############################################################################### | |
3 | # IPFire.org - An Open Source Firewall Solution # | |
4 | # Copyright (C) - IPFire Development Team <info@ipfire.org> # | |
5 | ############################################################################### | |
6 | ||
7 | import re | |
8 | import sys | |
9 | ||
10 | filelist = sys.argv[1:] | |
11 | ||
12 | lines = [] | |
13 | options_state = {} | |
14 | options_counter = {} | |
15 | ||
16 | first_file = True | |
17 | for filename in filelist: | |
18 | f = open(filename) | |
19 | ||
20 | for line in f.readlines(): | |
21 | # Strip newline. | |
22 | line = line.rstrip() | |
23 | ||
24 | if line.startswith("# Automatically generated file;"): | |
25 | continue | |
26 | ||
27 | if line.endswith("Kernel Configuration"): | |
28 | continue | |
29 | ||
30 | option = value = None | |
31 | ||
32 | m = re.match("^# (.*) is not set$", line) | |
33 | if m: | |
34 | option = m.group(1) | |
35 | value = "n" | |
36 | ||
37 | m = re.match("^(.*)=(.*)$", line) | |
38 | if m: | |
39 | option = m.group(1) | |
40 | value = m.group(2) | |
41 | ||
42 | if option: | |
43 | option_value = "%s=%s" % (option, value or "") | |
44 | ||
45 | try: | |
46 | options_counter[option_value] += 1 | |
47 | continue | |
48 | ||
49 | except KeyError: | |
50 | options_counter[option_value] = 1 | |
51 | ||
52 | if first_file: | |
53 | lines.append(line) | |
54 | ||
55 | f.close() | |
56 | first_file = False | |
57 | ||
58 | for line in lines: | |
59 | m = re.match("^# (.*) is not set$", line) | |
60 | if m: | |
61 | if options_counter.get("%s=n" % m.group(1), 0) == len(filelist): | |
62 | print "# %s is not set" % m.group(1) | |
63 | ||
64 | continue | |
65 | ||
66 | m = re.match("^(.*)=(.*)$", line) | |
67 | if m: | |
68 | if options_counter.get(m.group(0), 0) == len(filelist): | |
69 | print m.group(0) | |
70 | ||
71 | continue | |
72 | ||
73 | print line |