Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/225326
Change subject: Move slugify function into utils
......................................................................
Move slugify function into utils
Change-Id: I8386d7c2f023fbd2a19353fee670aaf68714a6d6
---
M quarry/web/app.py
M quarry/web/utils/__init__.py
2 files changed, 16 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/quarry/web
refs/changes/26/225326/1
diff --git a/quarry/web/app.py b/quarry/web/app.py
index 38e21b7..d293b39 100644
--- a/quarry/web/app.py
+++ b/quarry/web/app.py
@@ -5,10 +5,9 @@
from models.queryrun import QueryRun
from models.star import Star
from results import SQLiteResultReader
-from utils import json_formatter
+from utils import json_formatter, slugify
# This just provides the translit/long codec, unused otherwise
import translitcodec # NOQA
-import re
import json
import yaml
import output
@@ -39,8 +38,6 @@
app.session_interface = RedisSessionInterface()
-_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
-
class QueriesRangeBasedPagination(RangeBasedPagination):
@@ -70,16 +67,6 @@
else:
self.queryset = self.queryset.filter(
QueryRun.id < from_qrun_id)
-
-
-def slugify(text, delim=u'-'):
- """Generates an ASCII-only slug."""
- result = []
- for word in _punct_re.split(text.lower()):
- word = word.encode('translit/long')
- if word:
- result.append(word)
- return unicode(delim.join(result))
def get_user():
diff --git a/quarry/web/utils/__init__.py b/quarry/web/utils/__init__.py
index 6e6cb46..270c0a2 100644
--- a/quarry/web/utils/__init__.py
+++ b/quarry/web/utils/__init__.py
@@ -1,3 +1,8 @@
+import re
+
+_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
+
+
def datetime_json_formatter(dt):
try:
return dt.isoformat()
@@ -19,3 +24,13 @@
except TypeError:
pass
raise TypeError(dt)
+
+
+def slugify(text, delim=u'-'):
+ """Generates an ASCII-only slug."""
+ result = []
+ for word in _punct_re.split(text.lower()):
+ word = word.encode('translit/long')
+ if word:
+ result.append(word)
+ return unicode(delim.join(result))
--
To view, visit https://gerrit.wikimedia.org/r/225326
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8386d7c2f023fbd2a19353fee670aaf68714a6d6
Gerrit-PatchSet: 1
Gerrit-Project: analytics/quarry/web
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits