Packages update
This commit is contained in:
@@ -11,6 +11,10 @@
|
||||
import re
|
||||
import sys
|
||||
import errno
|
||||
try:
|
||||
from urllib.parse import quote_from_bytes as url_quote
|
||||
except ImportError:
|
||||
from urllib import quote as url_quote
|
||||
try:
|
||||
from thread import allocate_lock
|
||||
except ImportError:
|
||||
@@ -349,6 +353,21 @@ def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
|
||||
return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
|
||||
|
||||
|
||||
def unicode_urlencode(obj, charset='utf-8'):
|
||||
"""URL escapes a single bytestring or unicode string with the
|
||||
given charset if applicable to URL safe quoting under all rules
|
||||
that need to be considered under all supported Python versions.
|
||||
|
||||
If non strings are provided they are converted to their unicode
|
||||
representation first.
|
||||
"""
|
||||
if not isinstance(obj, basestring):
|
||||
obj = unicode(obj)
|
||||
if isinstance(obj, unicode):
|
||||
obj = obj.encode(charset)
|
||||
return unicode(url_quote(obj))
|
||||
|
||||
|
||||
class LRUCache(object):
|
||||
"""A simple LRU Cache implementation."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user