History

diffconfig: Update script to support python versions 2.5 through 3.3

Support past and active versions of python while maintaining backward compatibility. Script has been tested on python versions up to and including 3.3.X.

Mike Pagano committed 13 years ago

Commit c8272fa1 parent 6bf2e841 file · +13 −15Browse files

Showing the changes to scripts/diffconfig (1 of 1 file). Show all

Unified · Split

scripts/diffconfig+13−15
@@ -10,7 +10,7 @@ · 9 unmodified lines
10import sys, os10import sys, os
11 11
12def usage():12def usage():
13 print """Usage: diffconfig [-h] [-m] [<config1> <config2>]13 print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
14 14
15Diffconfig is a simple utility for comparing two .config files.15Diffconfig is a simple utility for comparing two .config files.
16Using standard diff to compare .config files often includes extraneous and16Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage: · 16 unmodified lines
33 EXT2_FS y -> n33 EXT2_FS y -> n
34 LOG_BUF_SHIFT 14 -> 1634 LOG_BUF_SHIFT 14 -> 16
35 PRINTK_TIME n -> y35 PRINTK_TIME n -> y
36"""36""")
37 sys.exit(0)37 sys.exit(0)
38 38
39# returns a dictionary of name/value pairs for config items in the file39# returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,23 @@ def print_config(op, config, value, new_value): · 14 unmodified lines
54 if merge_style:54 if merge_style:
55 if new_value:55 if new_value:
56 if new_value=="n":56 if new_value=="n":
57 print "# CONFIG_%s is not set" % config57 print("# CONFIG_%s is not set" % config)
58 else:58 else:
59 print "CONFIG_%s=%s" % (config, new_value)59 print("CONFIG_%s=%s" % (config, new_value))
60 else:60 else:
61 if op=="-":61 if op=="-":
62 print "-%s %s" % (config, value)62 print("-%s %s" % (config, value))
63 elif op=="+":63 elif op=="+":
64 print "+%s %s" % (config, new_value)64 print("+%s %s" % (config, new_value))
65 else:65 else:
66 print " %s %s -> %s" % (config, value, new_value)66 print(" %s %s -> %s" % (config, value, new_value))
67 67
68def main():68def main():
69 global merge_style69 global merge_style
70 70
71 # parse command line args71 # parse command line args
72 if ("-h" in sys.argv or "--help" in sys.argv):72 if ("-h" in sys.argv or "--help" in sys.argv):
73 usage()73 usage()
74 74
75 merge_style = 075 merge_style = 0
76 if "-m" in sys.argv:76 if "-m" in sys.argv:
@@ -79,15 +79,14 @@ def main(): · 2 unmodified lines
79 79
80 argc = len(sys.argv)80 argc = len(sys.argv)
81 if not (argc==1 or argc == 3):81 if not (argc==1 or argc == 3):
82 print "Error: incorrect number of arguments or unrecognized option"82 print("Error: incorrect number of arguments or unrecognized option")
83 usage()83 usage()
84 84
85 if argc == 1:85 if argc == 1:
86 # if no filenames given, assume .config and .config.old86 # if no filenames given, assume .config and .config.old
87 build_dir=""87 build_dir=""
88 if os.environ.has_key("KBUILD_OUTPUT"):88 if "KBUILD_OUTPUT" in os.environ:
89 build_dir = os.environ["KBUILD_OUTPUT"]+"/"89 build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90
91 configa_filename = build_dir + ".config.old"90 configa_filename = build_dir + ".config.old"
92 configb_filename = build_dir + ".config"91 configb_filename = build_dir + ".config"
93 else:92 else:
@@ -95,8 +94,8 @@ def main(): · 1 unmodified line
95 configb_filename = sys.argv[2]94 configb_filename = sys.argv[2]
96 95
97 try:96 try:
98 a = readconfig(file(configa_filename))97 a = readconfig(open(configa_filename))
99 b = readconfig(file(configb_filename))98 b = readconfig(open(configb_filename))
100 except (IOError):99 except (IOError):
101 e = sys.exc_info()[1]100 e = sys.exc_info()[1]
102 print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))101 print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
@@ -126,8 +125,7 @@ def main(): · 23 unmodified lines
126 125
127 # now print items in b but not in a126 # now print items in b but not in a
128 # (items from b that were in a were removed above)127 # (items from b that were in a were removed above)
129 new = b.keys()128 new = sorted(b.keys())
130 new.sort()
131 for config in new:129 for config in new:
132 print_config("+", config, None, b[config])130 print_config("+", config, None, b[config])
133 131

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t