From 1c416093518c7c358096802e911c00d29a810b18 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 20 Jun 2015 21:46:39 +0200 Subject: Make all examples Python 3-friendly. print -> print(). Skip 'from __future__ import print_function' by only having a single argument (to avoid interpretation as tuples in Python 2). Keeps the examples simple. --- examples/defconfig.py | 2 +- examples/eval_expr.py | 2 +- examples/help_grep.py | 17 +++++++---------- examples/print_refs.py | 2 +- examples/print_sym_info.py | 2 +- examples/print_tree.py | 2 +- examples/print_undefined.py | 4 ++-- 7 files changed, 14 insertions(+), 17 deletions(-) (limited to 'examples') diff --git a/examples/defconfig.py b/examples/defconfig.py index 3ed09fa..3e958e2 100644 --- a/examples/defconfig.py +++ b/examples/defconfig.py @@ -11,7 +11,7 @@ if os.path.exists(".config"): else: defconfig = conf.get_defconfig_filename() if defconfig is not None: - print "Using " + defconfig + print("Using" + defconfig) conf.load_config(defconfig) conf.write_config(".config") diff --git a/examples/eval_expr.py b/examples/eval_expr.py index f8e0f65..edb33e6 100644 --- a/examples/eval_expr.py +++ b/examples/eval_expr.py @@ -5,4 +5,4 @@ import kconfiglib import sys conf = kconfiglib.Config(sys.argv[1]) -print conf.eval("(TRACE_IRQFLAGS_SUPPORT || PPC32) && STACKTRACE_SUPPORT") +print(conf.eval("(TRACE_IRQFLAGS_SUPPORT || PPC32) && STACKTRACE_SUPPORT")) diff --git a/examples/help_grep.py b/examples/help_grep.py index 93b086a..61ac936 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -8,13 +8,13 @@ import kconfiglib import sys if len(sys.argv) < 3: - print 'Pass search string with SCRIPT_ARG="search string"' + print('Pass search string with SCRIPT_ARG="search string"') sys.exit(1) search_string = sys.argv[2].lower() conf = kconfiglib.Config(sys.argv[1]) -for item in conf.get_symbols() +\ +for item in conf.get_symbols() + \ conf.get_choices() + conf.get_menus() + conf.get_comments(): if item.is_symbol() or item.is_choice(): text = item.get_help() @@ -34,19 +34,16 @@ for item in conf.get_symbols() +\ # keep things simple fname, linenr = item.get_def_locations()[0] if item.is_symbol(): - print "config {0} at {1}:{2}:\n{3}".\ - format(item.get_name(), fname, linenr, text) + print("config {0} at {1}:{2}:\n{3}" + .format(item.get_name(), fname, linenr, text)) elif item.is_choice(): - print "choice at {0}:{1}:\n{2}".\ - format(fname, linenr, text) + print("choice at {0}:{1}:\n{2}".format(fname, linenr, text)) else: # Menu or comment fname, linenr = item.get_location() if item.is_menu(): - print 'menu "{0}" at {1}:{2}'.\ - format(text, fname, linenr) + print('menu "{0}" at {1}:{2}'.format(text, fname, linenr)) else: # Comment - print 'comment "{0}" at {1}:{2}'.\ - format(text, fname, linenr) + print('comment "{0}" at {1}:{2}'.format(text, fname, linenr)) diff --git a/examples/print_refs.py b/examples/print_refs.py index b2d9f5f..ea62223 100644 --- a/examples/print_refs.py +++ b/examples/print_refs.py @@ -10,4 +10,4 @@ conf = kconfiglib.Config(sys.argv[1]) x86 = conf["X86"] for sym in conf: if x86 in sym.get_referenced_symbols(): - print sym.get_name() + print(sym.get_name()) diff --git a/examples/print_sym_info.py b/examples/print_sym_info.py index 8c69cac..c913358 100644 --- a/examples/print_sym_info.py +++ b/examples/print_sym_info.py @@ -15,4 +15,4 @@ conf.load_config("$srctree/arch/x86/configs/i386_defconfig") # Print some information about a symbol. (The Config class implements # __getitem__() to provide a handy syntax for getting symbols.) -print conf["SERIAL_UARTLITE_CONSOLE"] +print(conf["SERIAL_UARTLITE_CONSOLE"]) diff --git a/examples/print_tree.py b/examples/print_tree.py index 35ad23e..1405ed5 100644 --- a/examples/print_tree.py +++ b/examples/print_tree.py @@ -4,7 +4,7 @@ import kconfiglib import sys def print_with_indent(s, indent): - print (" " * indent) + s + print((" " * indent) + s) def print_items(items, indent): for item in items: diff --git a/examples/print_undefined.py b/examples/print_undefined.py index 82a29d3..fb8120b 100644 --- a/examples/print_undefined.py +++ b/examples/print_undefined.py @@ -10,6 +10,6 @@ conf = kconfiglib.Config(sys.argv[1]) for sym in conf.get_symbols(): if not sym.is_defined(): - print sym.get_name() + print(sym.get_name()) for (filename, linenr) in sym.get_ref_locations(): - print " {0}:{1}".format(filename, linenr) + print(" {0}:{1}".format(filename, linenr)) -- cgit v1.2.3