diff options
author | Joe Robinson <joe@lc8n.com> | 2020-11-08 15:17:00 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2020-11-08 15:17:00 +0000 |
commit | fd9ede3a6cc2686dec98b4aa8bbaebb55e34b322 (patch) | |
tree | 02c3e72c373e6f541f9ffcca0a2cfb406707f069 | |
parent | d5f01c2f4ccc2cd83776d2a2e5ea30e8f5957eaf (diff) | |
parent | 19ad795fdc6cf2d24e2a40f8d5ee0b3f406e4acd (diff) |
Merge branch 'master' into 'master'
Upgrade print statements to python v3 syntax
See merge request CarpNet/wikiquery!2
-rwxr-xr-x | wikiquery | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -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) |