Update and integrate Suelta.

This commit is contained in:
Lance Stout
2012-07-29 17:22:16 -07:00
parent e4b4c67637
commit 695cd95657
32 changed files with 859 additions and 1505 deletions

View File

@@ -20,19 +20,13 @@ import sys
import stringprep
import unicodedata
from sleekxmpp.util import unicode
class StringPrepError(UnicodeError):
pass
def to_unicode(data):
"""Ensure that a given string is Unicode, regardless of Python version."""
if sys.version_info < (3, 0):
return unicode(data)
else:
return str(data)
def b1_mapping(char):
"""Map characters that are commonly mapped to nothing."""
return '' if stringprep.in_table_b1(char) else None
@@ -143,7 +137,7 @@ def create(nfkc=True, bidi=True, mappings=None,
"""
def profile(data, query=False):
try:
data = to_unicode(data)
data = unicode(data)
except UnicodeError:
raise StringPrepError