summaryrefslogtreecommitdiff
path: root/examples/help_grep.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2015-06-20 21:46:39 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2015-06-20 22:06:49 +0200
commit1c416093518c7c358096802e911c00d29a810b18 (patch)
tree35a5ce0b0e764c217a460bbf38706ae59a99304c /examples/help_grep.py
parent52c503dbb37d61013d8adb50c3929f089dfa3ffa (diff)
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.
Diffstat (limited to 'examples/help_grep.py')
-rw-r--r--examples/help_grep.py17
1 files changed, 7 insertions, 10 deletions
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))