X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/40300f9ea7fc541bd5f3878d98d4ff0ca4873d9c..1fded58d8ba2c00841c0c6e297385b8d0f3a7af4:/pokedex/__init__.py diff --git a/pokedex/__init__.py b/pokedex/__init__.py index 4af3fa0..499d8d2 100644 --- a/pokedex/__init__.py +++ b/pokedex/__init__.py @@ -15,7 +15,7 @@ def main(): # XXX there must be a better way to get Unicode argv # XXX this doesn't work on Windows durp - enc = sys.stdin.encoding + enc = sys.stdin.encoding or 'utf8' args = [_.decode(enc) for _ in args] # Find the command as a function in this file @@ -54,11 +54,11 @@ def command_load(*args): def command_setup(*args): session = connect() pokedex.db.load.load(session, verbose=False, drop_tables=True) - pokedex.lookup.open_index(session=session, recreate=True) + pokedex.lookup.PokedexLookup(session=session, recreate=True) def command_lookup(name): - results = pokedex.lookup.lookup(name) + results = pokedex.lookup.PokedexLookup().lookup(name) if not results: print "No matches." elif results[0].exact: @@ -66,8 +66,17 @@ def command_lookup(name): else: print "Fuzzy-matched:" - for object, language, exact in results: - print object.__tablename__, object.name, language + 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():