summaryrefslogtreecommitdiff
path: root/service/app/search
diff options
context:
space:
mode:
authorBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-07 16:27:52 -0300
committerBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-07 16:37:27 -0300
commitd4cf82682a1cc586628922f18fd0f501772717eb (patch)
tree7226db9e41e7e51cb945fe17c89acf877b10498d /service/app/search
parent719240d19bfcf5488a99d38cacccdbbeb94e30f8 (diff)
Search shouldn't be a module yet, because it only have one file
Diffstat (limited to 'service/app/search')
-rw-r--r--service/app/search/__init__.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/service/app/search/__init__.py b/service/app/search/__init__.py
deleted file mode 100644
index c89ae704..00000000
--- a/service/app/search/__init__.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from scanner import StringScanner, StringRegexp
-import re
-
-
-def _next_token():
- return StringRegexp('[^\s]+')
-
-
-def _separators():
- return StringRegexp('[\s&]+')
-
-
-def _compile_tag(compiled, token):
- tag = token.split(":").pop()
- if token[0] == "-":
- compiled["not_tags"].append(tag)
- else:
- compiled["tags"].append(tag)
- return compiled
-
-
-class SearchQuery:
-
- @staticmethod
- def compile(query):
- compiled = {"tags": [], "not_tags": []}
- sanitized_query = re.sub(r"['\"]", "", query.encode('utf8'))
- scanner = StringScanner(sanitized_query)
- first_token = True
- while not scanner.is_eos:
- token = scanner.scan(_next_token())
-
- if not token:
- scanner.skip(_separators())
- continue
-
- if ":" in token:
- compiled = _compile_tag(compiled, token)
- elif first_token:
- compiled["general"] = token
-
- if not first_token:
- first_token = True
-
- return compiled