Skip to content

Commit

Permalink
TradeDB.list_search is now whitespace agnostic.
Browse files Browse the repository at this point in the history
This allows 'dom. appliances' to match 'dom.appl', 'i Bootis' to match 'IBOOTIS' etc.
  • Loading branch information
kfsone committed Aug 14, 2014
1 parent de0d8c7 commit b6bde7e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,17 @@ def query(self, sql):
cur.execute(sql)
return cur


def fetch_all(self, sql):
for row in self.query(sql):
yield row


def list_search(self, listType, lookup, values):
match = None
needle = lookup.casefold()
needle = lookup.casefold().replace(" ", "").casefold()
for val in values:
if val.casefold().find(needle) > -1:
if val.casefold().replace(" ", "").find(needle) > -1:
if match:
raise ValueError("Ambiguity: %s '%s' could match %s or %s" % (
listType, lookup, match, val))
Expand Down

0 comments on commit b6bde7e

Please sign in to comment.