X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/b7268b5c97e6c0f5c2b92e5befb53d1a251e42b3..e56177f842707420f961dda29e17feef957ca8f4:/pokedex/__init__.py?ds=inline diff --git a/pokedex/__init__.py b/pokedex/__init__.py index 1c28b06..6a4ab95 100644 --- a/pokedex/__init__.py +++ b/pokedex/__init__.py @@ -13,6 +13,11 @@ def main(): command = sys.argv[1] args = sys.argv[2:] + # XXX there must be a better way to get Unicode argv + # XXX this doesn't work on Windows durp + enc = sys.stdin.encoding or 'utf8' + args = [_.decode(enc) for _ in args] + # Find the command as a function in this file func = globals().get("command_%s" % command, None) if func: @@ -53,14 +58,25 @@ def command_setup(*args): def command_lookup(name): - results, exact = pokedex.lookup.lookup(name) - if exact: + results = pokedex.lookup.lookup(name) + if not results: + print "No matches." + elif results[0].exact: print "Matched:" else: print "Fuzzy-matched:" - for object in results: - print object.__tablename__, object.name + for result in results: + if hasattr(result.object, 'full_name'): + name = result.object.full_name + else: + name = result.object.name + + print "%s: %s" % (result.object.__tablename__, name), + if result.language: + print "(%s in %s)" % (result.name, result.language) + else: + print def command_help():