summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwikiquery24
1 files changed, 12 insertions, 12 deletions
diff --git a/wikiquery b/wikiquery
index 565752a..ecfd0aa 100755
--- a/wikiquery
+++ b/wikiquery
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
import shlex
import optparse
@@ -20,7 +20,7 @@ def stringify(o):
return o.encode("utf-8", "replace")
def display(o):
- print stringify(o)
+ print (stringify(o))
def search(topic, index):
results = wikipedia.search(topic)
@@ -31,7 +31,7 @@ def search(topic, index):
try:
display(wikipedia.summary(results[index]))
except IndexError:
- print "index out of range, options are: [%s]" % stringify(results)
+ print ("index out of range, options are: [%s]" % stringify(results))
else:
display(results)
@@ -43,7 +43,7 @@ def url(topic, index):
try:
display(wikipedia.page(e.options[index]).url)
except IndexError:
- print "index out of range, options are: [%s]" % stringify(e.options)
+ print ("index out of range, options are: [%s]" % stringify(e.options))
else:
display(e.options)
else:
@@ -57,12 +57,12 @@ def summary(topic, index):
try:
display(wikipedia.summary(e.options[index]))
except IndexError:
- print "index out of range, options are: [%s]" % stringify(e.options)
+ print ("index out of range, options are: [%s]" % stringify(e.options))
else:
display(e.options)
- except wikipedia.exceptions.PageError as e:
- print "No wikipedia results found for %s" %topic
-
+ except wikipedia.exceptions.PageError as e:
+ print ("No wikipedia results found for %s" %topic)
+
def parse_args():
args = sys.argv[1:]
@@ -81,20 +81,20 @@ def main():
options, args = parse_args()
if options.version:
- print version
+ print (version)
sys.exit(0)
-
+
if args:
topic = args.pop(0)
while len(args) > 0 and not(isinstance(args[0], (int,long))):
topic += " " + args.pop(0)
-
+
index = int(args.pop(0)) if args else None
if options.search:
search(topic, index)
elif options.url:
- url(topic, index)
+ url(topic, index)
else:
summary(topic, index)