equal
deleted
inserted
replaced
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 |
21 |
22 from warnings import warn |
22 from warnings import warn |
23 from datetime import time, datetime, timedelta |
23 from datetime import time, datetime, timedelta |
24 |
24 |
25 from six import text_type |
25 from six import PY2, text_type |
26 from six.moves.urllib.parse import parse_qs, parse_qsl, quote as urlquote, unquote as urlunquote, urlsplit, urlunsplit |
26 from six.moves.urllib.parse import parse_qs, parse_qsl, quote as urlquote, unquote as urlunquote, urlsplit, urlunsplit |
27 |
27 |
28 from logilab.common.decorators import cached |
28 from logilab.common.decorators import cached |
29 from logilab.common.deprecation import deprecated |
29 from logilab.common.deprecation import deprecated |
30 from logilab.common.date import ustrftime, strptime, todate, todatetime |
30 from logilab.common.date import ustrftime, strptime, todate, todatetime |
311 def url_quote(self, value, safe=''): |
311 def url_quote(self, value, safe=''): |
312 """urllib.quote is not unicode safe, use this method to do the |
312 """urllib.quote is not unicode safe, use this method to do the |
313 necessary encoding / decoding. Also it's designed to quote each |
313 necessary encoding / decoding. Also it's designed to quote each |
314 part of a url path and so the '/' character will be encoded as well. |
314 part of a url path and so the '/' character will be encoded as well. |
315 """ |
315 """ |
316 if isinstance(value, unicode): |
316 if PY2 and isinstance(value, unicode): |
317 quoted = urlquote(value.encode(self.encoding), safe=safe) |
317 quoted = urlquote(value.encode(self.encoding), safe=safe) |
318 return unicode(quoted, self.encoding) |
318 return unicode(quoted, self.encoding) |
319 return urlquote(str(value), safe=safe) |
319 return urlquote(str(value), safe=safe) |
320 |
320 |
321 def url_unquote(self, quoted): |
321 def url_unquote(self, quoted): |