summaryrefslogtreecommitdiff
path: root/examples/searchParserAppDemo.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/searchParserAppDemo.py')
-rw-r--r--examples/searchParserAppDemo.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/examples/searchParserAppDemo.py b/examples/searchParserAppDemo.py
index d1bf8ba..c608132 100644
--- a/examples/searchParserAppDemo.py
+++ b/examples/searchParserAppDemo.py
@@ -1,15 +1,24 @@
from searchparser import SearchQueryParser
-products = [ "grape juice", "grape jelly", "orange juice", "orange jujubees",
- "strawberry jam", "prune juice", "prune butter", "orange marmalade",
- "grapefruit juice" ]
+products = [
+ "grape juice",
+ "grape jelly",
+ "orange juice",
+ "orange jujubees",
+ "strawberry jam",
+ "prune juice",
+ "prune butter",
+ "orange marmalade",
+ "grapefruit juice",
+]
+
class FruitSearchParser(SearchQueryParser):
def GetWord(self, word):
- return { p for p in products if p.startswith(word + " ") }
+ return {p for p in products if p.startswith(word + " ")}
def GetWordWildcard(self, word):
- return { p for p in products if p.startswith(word[:-1]) }
+ return {p for p in products if p.startswith(word[:-1])}
def GetQuotes(self, search_string, tmp_result):
result = set()
@@ -17,7 +26,7 @@ class FruitSearchParser(SearchQueryParser):
return result
def GetNot(self, not_set):
- return set( products ) - not_set
+ return set(products) - not_set
parser = FruitSearchParser()
@@ -31,4 +40,4 @@ tests = """\
for t in tests:
print(t.strip())
print(parser.Parse(t))
- print('')
+ print("")