projects
/
zzz-pokedex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
cfbbcde
)
Let lookup accept hex/octal/binary numbers.
author
Eevee
<git@veekun.com>
Wed, 28 Apr 2010 17:26:27 +0000
(10:26 -0700)
committer
Eevee
<git@veekun.com>
Wed, 28 Apr 2010 18:37:12 +0000
(11:37 -0700)
pokedex/lookup.py
patch
|
blob
|
history
diff --git
a/pokedex/lookup.py
b/pokedex/lookup.py
index
115e9f0
..
ce5bb76
100644
(file)
--- a/
pokedex/lookup.py
+++ b/
pokedex/lookup.py
@@
-387,13
+387,20
@@
class PokedexLookup(object):
# Do different things depending what the query looks like
# Note: Term objects do an exact match, so we don't have to worry about
# a query parser tripping on weird characters in the input
# Do different things depending what the query looks like
# Note: Term objects do an exact match, so we don't have to worry about
# a query parser tripping on weird characters in the input
+ try:
+ # Let Python try to convert to a number, so 0xff works
+ name_as_number = int(name, base=0)
+ except ValueError:
+ # Oh well
+ name_as_number = None
+
if '*' in name or '?' in name:
exact_only = True
query = whoosh.query.Wildcard(u'name', name)
if '*' in name or '?' in name:
exact_only = True
query = whoosh.query.Wildcard(u'name', name)
- elif
rx_is_number.match(name)
:
+ elif
name_as_number is not None
:
# Don't spell-check numbers!
exact_only = True
# Don't spell-check numbers!
exact_only = True
- query = whoosh.query.Term(u'row_id',
name
)
+ query = whoosh.query.Term(u'row_id',
unicode(name_as_number)
)
else:
# Not an integer
query = whoosh.query.Term(u'name', name)
else:
# Not an integer
query = whoosh.query.Term(u'name', name)