python3: get urllib/urlparse/htmlparser from six (#39092)

This commit is contained in:
Frédéric Péters 2020-01-19 19:09:41 +01:00
parent 4f9bb8b161
commit 27af09b510
4 changed files with 12 additions and 18 deletions

View File

@ -14,9 +14,8 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # 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.html import strip_tags
from django.utils.six.moves.html_parser import HTMLParser
from haystack import indexes from haystack import indexes

View File

@ -14,10 +14,10 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import urlparse
import base64 import base64
from dateutil.parser import parse as parse_datetime from dateutil.parser import parse as parse_datetime
from django.utils.six.moves.urllib import parse as urlparse
import requests import requests
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter

View File

@ -22,13 +22,13 @@ import json
import random import random
import re import re
import requests import requests
import urllib
import urlparse
from django.conf import settings from django.conf import settings
from django.core.cache import cache from django.core.cache import cache
from django.http import HttpResponse, HttpResponseBadRequest 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): def sign_url(url, key, algo='sha256', timestamp=None, nonce=None):
parsed = urlparse.urlparse(url) parsed = urlparse.urlparse(url)
@ -44,12 +44,12 @@ def sign_query(query, key, algo='sha256', timestamp=None, nonce=None):
new_query = query new_query = query
if new_query: if new_query:
new_query += '&' new_query += '&'
new_query += urllib.urlencode(( new_query += urlencode((
('algo', algo), ('algo', algo),
('timestamp', timestamp), ('timestamp', timestamp),
('nonce', nonce))) ('nonce', nonce)))
signature = base64.b64encode(sign_string(new_query, key, algo=algo)) signature = base64.b64encode(sign_string(new_query, key, algo=algo))
new_query += '&signature=' + urllib.quote(signature) new_query += '&signature=' + quote(signature)
return new_query return new_query
def sign_string(s, key, algo='sha256', timedelta=30): 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'): if request.session.get('mellon_session'):
mellon = request.session['mellon_session'] mellon = request.session['mellon_session']
nameid = mellon['name_id_content'] nameid = mellon['name_id_content']
url += '&NameID=' + urllib.quote(nameid) url += '&NameID=' + quote(nameid)
url = sign_url(url, wcs_site.get('secret')) url = sign_url(url, wcs_site.get('secret'))
@ -153,17 +153,12 @@ def get_wcs_data(endpoint, params=None):
wcs_site_url += '/' wcs_site_url += '/'
url = wcs_site_url + endpoint url = wcs_site_url + endpoint
if params: if not params:
params = params.copy()
for param, value in params.items():
if isinstance(value, unicode):
params[param] = value.encode('utf-8')
else:
params = {} params = {}
params['orig'] = wcs_site.get('orig') params['orig'] = wcs_site.get('orig')
if params: if params:
url += '?' + urllib.urlencode(params.items()) url += '?' + urlencode(params.items())
url = sign_url(url, wcs_site.get('secret')) url = sign_url(url, wcs_site.get('secret'))
response = requests.get(url) response = requests.get(url)

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import json import json
import urllib
from django.conf import settings from django.conf import settings
from django.contrib.auth import logout as auth_logout 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 import template
from django.template import RequestContext from django.template import RequestContext
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.http import quote
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView from django.views.generic import TemplateView
@ -52,7 +52,7 @@ def login(request, *args, **kwargs):
if not 'next' in request.GET: if not 'next' in request.GET:
return HttpResponseRedirect(resolve_url('mellon_login')) return HttpResponseRedirect(resolve_url('mellon_login'))
return HttpResponseRedirect(resolve_url('mellon_login') + '?next=' 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) return auth_views.login(request, *args, **kwargs)
def logout(request, next_page=None): def logout(request, next_page=None):