common: add escape() method for python3
This commit is contained in:
parent
d009b35ab2
commit
c028af586b
|
@ -2,11 +2,15 @@ import os.path
|
|||
import os
|
||||
import random
|
||||
import logging
|
||||
import cgi
|
||||
from datetime import date
|
||||
|
||||
import six
|
||||
|
||||
if six.PY3:
|
||||
import html
|
||||
else:
|
||||
import cgi
|
||||
|
||||
__all__ = ['PaymentCommon', 'URL', 'HTML', 'RANDOM', 'RECEIVED', 'ACCEPTED',
|
||||
'PAID', 'ERROR', 'WAITING']
|
||||
|
||||
|
@ -162,7 +166,10 @@ class Form(object):
|
|||
return s
|
||||
|
||||
def escape(self, s):
|
||||
return cgi.escape(force_text(s, self.encoding).encode(self.encoding))
|
||||
if six.PY3:
|
||||
return html.escape(force_text(s, self.encoding))
|
||||
else:
|
||||
return cgi.escape(force_text(s, self.encoding)).encode(self.encoding)
|
||||
|
||||
def __str__(self):
|
||||
s = '<form method="%s" action="%s">' % (self.method, self.url)
|
||||
|
|
Loading…
Reference in New Issue