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
1010 import sys, os
1111
1212 def usage():
13− print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
13+ print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
1414
1515 Diffconfig is a simple utility for comparing two .config files.
1616 Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage: · 16 unmodified lines
3333 EXT2_FS y -> n
3434 LOG_BUF_SHIFT 14 -> 16
3535 PRINTK_TIME n -> y
36−"""
36+""")
3737 sys.exit(0)
3838
3939 # 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
5454 if merge_style:
5555 if new_value:
5656 if new_value=="n":
57− print "# CONFIG_%s is not set" % config
57+ print("# CONFIG_%s is not set" % config)
5858 else:
59− print "CONFIG_%s=%s" % (config, new_value)
59+ print("CONFIG_%s=%s" % (config, new_value))
6060 else:
6161 if op=="-":
62− print "-%s %s" % (config, value)
62+ print("-%s %s" % (config, value))
6363 elif op=="+":
64− print "+%s %s" % (config, new_value)
64+ print("+%s %s" % (config, new_value))
6565 else:
66− print " %s %s -> %s" % (config, value, new_value)
66+ print(" %s %s -> %s" % (config, value, new_value))
6767
6868 def main():
6969 global merge_style
7070
7171 # parse command line args
7272 if ("-h" in sys.argv or "--help" in sys.argv):
73− usage()
73+ usage()
7474
7575 merge_style = 0
7676 if "-m" in sys.argv:
@@ -79,15 +79,14 @@ def main(): · 2 unmodified lines
7979
8080 argc = len(sys.argv)
8181 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")
8383 usage()
8484
8585 if argc == 1:
8686 # if no filenames given, assume .config and .config.old
8787 build_dir=""
88− if os.environ.has_key("KBUILD_OUTPUT"):
88+ if "KBUILD_OUTPUT" in os.environ:
8989 build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90−
9190 configa_filename = build_dir + ".config.old"
9291 configb_filename = build_dir + ".config"
9392 else:
@@ -95,8 +94,8 @@ def main(): · 1 unmodified line
9594 configb_filename = sys.argv[2]
9695
9796 try:
98− a = readconfig(file(configa_filename))
99− b = readconfig(file(configb_filename))
97+ a = readconfig(open(configa_filename))
98+ b = readconfig(open(configb_filename))
10099 except (IOError):
101100 e = sys.exc_info()[1]
102101 print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
@@ -126,8 +125,7 @@ def main(): · 23 unmodified lines
126125
127126 # now print items in b but not in a
128127 # (items from b that were in a were removed above)
129− new = b.keys()
130− new.sort()
128+ new = sorted(b.keys())
131129 for config in new:
132130 print_config("+", config, None, b[config])
133131

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