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