summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-01-19 18:09:41 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-03-17 18:06:44 (GMT)
commit27af09b510876cc5db46da3aa74f5eaadc6bc0a3 (patch)
tree791423e989a00f5da90a51186b14557462bda1e9
parent4f9bb8b1617b97dcb57a1ab01aeefa1de7521eb4 (diff)
downloadwelco-27af09b510876cc5db46da3aa74f5eaadc6bc0a3.zip
welco-27af09b510876cc5db46da3aa74f5eaadc6bc0a3.tar.gz
welco-27af09b510876cc5db46da3aa74f5eaadc6bc0a3.tar.bz2
python3: get urllib/urlparse/htmlparser from six (#39092)
-rw-r--r--welco/kb/search_indexes.py3
-rw-r--r--welco/sources/mail/maarch.py2
-rw-r--r--welco/utils.py21
-rw-r--r--welco/views.py4
4 files changed, 12 insertions, 18 deletions
diff --git a/welco/kb/search_indexes.py b/welco/kb/search_indexes.py
index d0ed587..f4f388b 100644
--- a/welco/kb/search_indexes.py
+++ b/welco/kb/search_indexes.py
@@ -14,9 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from HTMLParser import HTMLParser
-
from django.utils.html import strip_tags
+from django.utils.six.moves.html_parser import HTMLParser
from haystack import indexes
diff --git a/welco/sources/mail/maarch.py b/welco/sources/mail/maarch.py
index 8021a88..3899500 100644
--- a/welco/sources/mail/maarch.py
+++ b/welco/sources/mail/maarch.py
@@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import urlparse
import base64
from dateutil.parser import parse as parse_datetime
+from django.utils.six.moves.urllib import parse as urlparse
import requests
from requests.adapters import HTTPAdapter
diff --git a/welco/utils.py b/welco/utils.py
index dc103e5..ebedf7e 100644
--- a/welco/utils.py
+++ b/welco/utils.py
@@ -22,13 +22,13 @@ import json
import random
import re
import requests
-import urllib
-import urlparse
from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseBadRequest
-from django.utils.http import urlencode
+from django.utils.http import urlencode, quote
+from django.utils.six.moves.urllib import parse as urlparse
+
def sign_url(url, key, algo='sha256', timestamp=None, nonce=None):
parsed = urlparse.urlparse(url)
@@ -44,12 +44,12 @@ def sign_query(query, key, algo='sha256', timestamp=None, nonce=None):
new_query = query
if new_query:
new_query += '&'
- new_query += urllib.urlencode((
+ new_query += urlencode((
('algo', algo),
('timestamp', timestamp),
('nonce', nonce)))
signature = base64.b64encode(sign_string(new_query, key, algo=algo))
- new_query += '&signature=' + urllib.quote(signature)
+ new_query += '&signature=' + quote(signature)
return new_query
def sign_string(s, key, algo='sha256', timedelta=30):
@@ -134,7 +134,7 @@ def push_wcs_formdata(request, formdef_reference, context=None):
if request.session.get('mellon_session'):
mellon = request.session['mellon_session']
nameid = mellon['name_id_content']
- url += '&NameID=' + urllib.quote(nameid)
+ url += '&NameID=' + quote(nameid)
url = sign_url(url, wcs_site.get('secret'))
@@ -153,17 +153,12 @@ def get_wcs_data(endpoint, params=None):
wcs_site_url += '/'
url = wcs_site_url + endpoint
- if params:
- params = params.copy()
- for param, value in params.items():
- if isinstance(value, unicode):
- params[param] = value.encode('utf-8')
- else:
+ if not params:
params = {}
params['orig'] = wcs_site.get('orig')
if params:
- url += '?' + urllib.urlencode(params.items())
+ url += '?' + urlencode(params.items())
url = sign_url(url, wcs_site.get('secret'))
response = requests.get(url)
diff --git a/welco/views.py b/welco/views.py
index ad6ed49..2efa6f3 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
-import urllib
from django.conf import settings
from django.contrib.auth import logout as auth_logout
@@ -29,6 +28,7 @@ from django.shortcuts import resolve_url
from django import template
from django.template import RequestContext
from django.utils.encoding import force_text
+from django.utils.http import quote
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
@@ -52,7 +52,7 @@ def login(request, *args, **kwargs):
if not 'next' in request.GET:
return HttpResponseRedirect(resolve_url('mellon_login'))
return HttpResponseRedirect(resolve_url('mellon_login') + '?next='
- + urllib.quote(request.GET.get('next')))
+ + quote(request.GET.get('next')))
return auth_views.login(request, *args, **kwargs)
def logout(request, next_page=None):