mirror of
https://github.com/django/django.git
synced 2025-09-23 02:33:31 +00:00
Moved django.views.decorators.cache.compress_string into django.utils.text
git-svn-id: http://code.djangoproject.com/svn/django/trunk@175 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b68c478aa5
commit
912253371d
2 changed files with 13 additions and 11 deletions
|
@ -106,3 +106,13 @@ def phone2numeric(phone):
|
|||
's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
|
||||
'y': '9', 'x': '9'}.get(m.group(0).lower())
|
||||
return letters.sub(char2number, phone)
|
||||
|
||||
# From http://www.xhaus.com/alan/python/httpcomp.html#gzip
|
||||
# Used with permission.
|
||||
def compress_string(s):
|
||||
import cStringIO, gzip
|
||||
zbuf = cStringIO.StringIO()
|
||||
zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
|
||||
zfile.write(s)
|
||||
zfile.close()
|
||||
return zbuf.getvalue()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue