make all syntax compatible with 3.1 and 2.5
--HG-- branch : trunk
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
if sys.version_info > (3, 0):
|
||||
def u(s):
|
||||
return s
|
||||
else:
|
||||
def u(s):
|
||||
return unicode(s)
|
||||
|
||||
class _escape:
|
||||
def __init__(self):
|
||||
self.escape = {
|
||||
u'"' : u'"', u'<' : u'<', u'>' : u'>',
|
||||
u'&' : u'&', u"'" : u''',
|
||||
u('"') : u('"'), u('<') : u('<'), u('>') : u('>'),
|
||||
u('&') : u('&'), u("'") : u('''),
|
||||
}
|
||||
self.charef_rex = re.compile(u"|".join(self.escape.keys()))
|
||||
self.charef_rex = re.compile(u("|").join(self.escape.keys()))
|
||||
|
||||
def _replacer(self, match):
|
||||
return self.escape[match.group(0)]
|
||||
|
||||
Reference in New Issue
Block a user