From b6bde7e0e217c256ad2f01d4fa74f8da0797b083 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Thu, 14 Aug 2014 16:24:35 -0700 Subject: [PATCH] TradeDB.list_search is now whitespace agnostic. This allows 'dom. appliances' to match 'dom.appl', 'i Bootis' to match 'IBOOTIS' etc. --- tradedb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tradedb.py b/tradedb.py index 77b45e5d..682bfdc9 100644 --- a/tradedb.py +++ b/tradedb.py @@ -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))