Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (19 sloc) 699 Bytes
import re
from unicodedata import normalize
# From http://flask.pocoo.org/snippets/5/
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
def slugify(text, delim=u'-'):
"""
Generates a slug that will only use ASCII, be all lowercase, have no
spaces, and otherwise be nice for filenames, identifiers, and urls.
"""
result = []
for word in _punct_re.split(text.lower()):
word = normalize('NFKD', unicode(word)).encode('ascii', 'ignore')
if word:
result.append(word)
return unicode(delim.join(result))
def chunk(li, n):
"""Yield succesive n-size chunks from l."""
for i in xrange(0, len(li), n):
yield li[i:i+n]
Something went wrong with that request. Please try again.