Remove old workarounds for Python 2.3.
This commit is contained in:
parent
2654ee9d56
commit
3fc9c10caa
|
@ -21,34 +21,9 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
|
||||||
import sys, warnings
|
import stringprep
|
||||||
|
import unicodedata
|
||||||
if sys.version_info < (2,3,2):
|
from encodings import idna
|
||||||
import re
|
|
||||||
|
|
||||||
class IDNA:
|
|
||||||
dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
|
|
||||||
def nameprep(self, label):
|
|
||||||
return label.lower()
|
|
||||||
|
|
||||||
idna = IDNA()
|
|
||||||
|
|
||||||
crippled = True
|
|
||||||
|
|
||||||
warnings.warn("Accented and non-Western Jabber IDs will not be properly "
|
|
||||||
"case-folded with this version of Python, resulting in "
|
|
||||||
"incorrect protocol-level behavior. It is strongly "
|
|
||||||
"recommended you upgrade to Python 2.3.2 or newer if you "
|
|
||||||
"intend to use Twisted's Jabber support.")
|
|
||||||
|
|
||||||
else:
|
|
||||||
import stringprep
|
|
||||||
import unicodedata
|
|
||||||
from encodings import idna
|
|
||||||
|
|
||||||
crippled = False
|
|
||||||
|
|
||||||
del sys, warnings
|
|
||||||
|
|
||||||
class ILookupTable:
|
class ILookupTable:
|
||||||
""" Interface for character lookup classes. """
|
""" Interface for character lookup classes. """
|
||||||
|
@ -222,44 +197,30 @@ class NamePrep:
|
||||||
raise UnicodeError, "Invalid trailing hyphen-minus"
|
raise UnicodeError, "Invalid trailing hyphen-minus"
|
||||||
return label
|
return label
|
||||||
|
|
||||||
if crippled:
|
C_11 = LookupTableFromFunction(stringprep.in_table_c11)
|
||||||
case_map = MappingTableFromFunction(lambda c: c.lower())
|
C_12 = LookupTableFromFunction(stringprep.in_table_c12)
|
||||||
nodeprep = Profile(mappings=[case_map],
|
C_21 = LookupTableFromFunction(stringprep.in_table_c21)
|
||||||
normalize=False,
|
C_22 = LookupTableFromFunction(stringprep.in_table_c22)
|
||||||
prohibiteds=[LookupTable([u' ', u'"', u'&', u"'", u'/',
|
C_3 = LookupTableFromFunction(stringprep.in_table_c3)
|
||||||
u':', u'<', u'>', u'@'])],
|
C_4 = LookupTableFromFunction(stringprep.in_table_c4)
|
||||||
check_unassigneds=False,
|
C_5 = LookupTableFromFunction(stringprep.in_table_c5)
|
||||||
check_bidi=False)
|
C_6 = LookupTableFromFunction(stringprep.in_table_c6)
|
||||||
|
C_7 = LookupTableFromFunction(stringprep.in_table_c7)
|
||||||
|
C_8 = LookupTableFromFunction(stringprep.in_table_c8)
|
||||||
|
C_9 = LookupTableFromFunction(stringprep.in_table_c9)
|
||||||
|
|
||||||
resourceprep = Profile(normalize=False,
|
B_1 = EmptyMappingTable(stringprep.in_table_b1)
|
||||||
check_unassigneds=False,
|
B_2 = MappingTableFromFunction(stringprep.map_table_b2)
|
||||||
check_bidi=False)
|
|
||||||
|
|
||||||
else:
|
nodeprep = Profile(mappings=[B_1, B_2],
|
||||||
C_11 = LookupTableFromFunction(stringprep.in_table_c11)
|
prohibiteds=[C_11, C_12, C_21, C_22,
|
||||||
C_12 = LookupTableFromFunction(stringprep.in_table_c12)
|
C_3, C_4, C_5, C_6, C_7, C_8, C_9,
|
||||||
C_21 = LookupTableFromFunction(stringprep.in_table_c21)
|
LookupTable([u'"', u'&', u"'", u'/',
|
||||||
C_22 = LookupTableFromFunction(stringprep.in_table_c22)
|
u':', u'<', u'>', u'@'])])
|
||||||
C_3 = LookupTableFromFunction(stringprep.in_table_c3)
|
|
||||||
C_4 = LookupTableFromFunction(stringprep.in_table_c4)
|
|
||||||
C_5 = LookupTableFromFunction(stringprep.in_table_c5)
|
|
||||||
C_6 = LookupTableFromFunction(stringprep.in_table_c6)
|
|
||||||
C_7 = LookupTableFromFunction(stringprep.in_table_c7)
|
|
||||||
C_8 = LookupTableFromFunction(stringprep.in_table_c8)
|
|
||||||
C_9 = LookupTableFromFunction(stringprep.in_table_c9)
|
|
||||||
|
|
||||||
B_1 = EmptyMappingTable(stringprep.in_table_b1)
|
resourceprep = Profile(mappings=[B_1,],
|
||||||
B_2 = MappingTableFromFunction(stringprep.map_table_b2)
|
prohibiteds=[C_12, C_21, C_22,
|
||||||
|
C_3, C_4, C_5, C_6, C_7, C_8, C_9])
|
||||||
nodeprep = Profile(mappings=[B_1, B_2],
|
|
||||||
prohibiteds=[C_11, C_12, C_21, C_22,
|
|
||||||
C_3, C_4, C_5, C_6, C_7, C_8, C_9,
|
|
||||||
LookupTable([u'"', u'&', u"'", u'/',
|
|
||||||
u':', u'<', u'>', u'@'])])
|
|
||||||
|
|
||||||
resourceprep = Profile(mappings=[B_1,],
|
|
||||||
prohibiteds=[C_12, C_21, C_22,
|
|
||||||
C_3, C_4, C_5, C_6, C_7, C_8, C_9])
|
|
||||||
|
|
||||||
nameprep = NamePrep()
|
nameprep = NamePrep()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue