add search command (#33)

* add search command
This commit is contained in:
Dave Gallant
2019-10-04 21:06:53 -04:00
committed by GitHub
parent 59e37a9105
commit ac46f2ae27
8 changed files with 87 additions and 73 deletions

13
rfd/search.py Normal file
View File

@@ -0,0 +1,13 @@
def search_threads(threads, keyword=None):
"""Match deal title and dealer names with keyword specified."""
if keyword is None:
return
keyword = str(keyword)
for deal in threads:
if keyword.lower() in deal.title.lower() or (
deal.dealer_name and keyword.lower() in deal.dealer_name.lower()
):
yield deal