##// END OF EJS Templates
python3: fixed urlparse import
super-admin -
r4919:5198086f default
parent child Browse files
Show More
@@ -18,7 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import urlparse
21 import urllib.parse
22
22
23 import mock
23 import mock
24 import pytest
24 import pytest
@@ -147,7 +147,7 b' class TestLoginController(object):'
147 h.route_path('repo_summary', repo_name=HG_REPO, _query=kwargs),
147 h.route_path('repo_summary', repo_name=HG_REPO, _query=kwargs),
148 status=302)
148 status=302)
149
149
150 response_query = urlparse.parse_qsl(response.location)
150 response_query = urllib.parse.urlparse.parse_qsl(response.location)
151 assert 'branch=stable' in response_query[0][1]
151 assert 'branch=stable' in response_query[0][1]
152
152
153 def test_login_form_with_get_args(self):
153 def test_login_form_with_get_args(self):
@@ -24,7 +24,7 b' import datetime'
24 import formencode
24 import formencode
25 import formencode.htmlfill
25 import formencode.htmlfill
26 import logging
26 import logging
27 import urlparse
27 import urllib.parse
28 import requests
28 import requests
29
29
30 from pyramid.httpexceptions import HTTPFound
30 from pyramid.httpexceptions import HTTPFound
@@ -90,7 +90,7 b' def store_user_in_session(session, usern'
90
90
91 def get_came_from(request):
91 def get_came_from(request):
92 came_from = safe_str(request.GET.get('came_from', ''))
92 came_from = safe_str(request.GET.get('came_from', ''))
93 parsed = urlparse.urlparse(came_from)
93 parsed = urllib.parse.urlparse.urlparse(came_from)
94 allowed_schemes = ['http', 'https']
94 allowed_schemes = ['http', 'https']
95 default_came_from = h.route_path('home')
95 default_came_from = h.route_path('home')
96 if parsed.scheme and parsed.scheme not in allowed_schemes:
96 if parsed.scheme and parsed.scheme not in allowed_schemes:
@@ -25,7 +25,7 b' import logging'
25 import signal
25 import signal
26 import tempfile
26 import tempfile
27 from subprocess import Popen, PIPE
27 from subprocess import Popen, PIPE
28 import urlparse
28 import urllib.parse
29
29
30 from .base import VcsServer
30 from .base import VcsServer
31
31
@@ -202,7 +202,7 b' class SubversionTunnelWrapper(object):'
202 if not first_response:
202 if not first_response:
203 return self.fail("Repository name cannot be extracted")
203 return self.fail("Repository name cannot be extracted")
204
204
205 url_parts = urlparse.urlparse(first_response['url'])
205 url_parts = urllib.parse.urlparse.urlparse(first_response['url'])
206
206
207 self.server.repo_name = self._match_repo_name(url_parts.path.strip('/'))
207 self.server.repo_name = self._match_repo_name(url_parts.path.strip('/'))
208
208
@@ -27,7 +27,7 b' import re'
27 import os
27 import os
28 import lxml
28 import lxml
29 import logging
29 import logging
30 import urlparse
30 import urllib.parse
31 import bleach
31 import bleach
32
32
33 from mako.lookup import TemplateLookup
33 from mako.lookup import TemplateLookup
@@ -142,7 +142,7 b' def relative_path(path, request_path, is'
142 # skip data, anchor, invalid links
142 # skip data, anchor, invalid links
143 return path
143 return path
144
144
145 is_absolute = bool(urlparse.urlparse(path).netloc)
145 is_absolute = bool(urllib.parse.urlparse.urlparse(path).netloc)
146 if is_absolute:
146 if is_absolute:
147 return path
147 return path
148
148
@@ -25,7 +25,7 b" It's implemented with basic auth functio"
25 import os
25 import os
26 import re
26 import re
27 import logging
27 import logging
28 import urlparse
28 import urllib.parse
29
29
30 import rhodecode
30 import rhodecode
31 from rhodecode.lib import utils
31 from rhodecode.lib import utils
@@ -123,7 +123,7 b' class SimpleGit(simplevcs.SimpleVCS):'
123 path = environ['PATH_INFO']
123 path = environ['PATH_INFO']
124
124
125 if path.endswith('/info/refs'):
125 if path.endswith('/info/refs'):
126 query = urlparse.parse_qs(environ['QUERY_STRING'])
126 query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'])
127 service_cmd = query.get('service', [''])[0]
127 service_cmd = query.get('service', [''])[0]
128 return self._ACTION_MAPPING.get(service_cmd, 'pull')
128 return self._ACTION_MAPPING.get(service_cmd, 'pull')
129
129
@@ -24,7 +24,7 b' SimpleHG middleware for handling mercuri'
24 """
24 """
25
25
26 import logging
26 import logging
27 import urlparse
27 import urllib.parse
28 import urllib.request, urllib.parse, urllib.error
28 import urllib.request, urllib.parse, urllib.error
29
29
30 from rhodecode.lib import utils
30 from rhodecode.lib import utils
@@ -135,7 +135,7 b' class SimpleHg(simplevcs.SimpleVCS):'
135 :param environ:
135 :param environ:
136 """
136 """
137 default = 'push'
137 default = 'push'
138 query = urlparse.parse_qs(environ['QUERY_STRING'],
138 query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'],
139 keep_blank_values=True)
139 keep_blank_values=True)
140
140
141 if 'cmd' in query:
141 if 'cmd' in query:
@@ -21,7 +21,7 b''
21 import base64
21 import base64
22 import logging
22 import logging
23 import urllib.request, urllib.parse, urllib.error
23 import urllib.request, urllib.parse, urllib.error
24 import urlparse
24 import urllib.parse
25
25
26 import requests
26 import requests
27 from pyramid.httpexceptions import HTTPNotAcceptable
27 from pyramid.httpexceptions import HTTPNotAcceptable
@@ -123,7 +123,7 b' class SimpleSvnApp(object):'
123
123
124 def _get_url(self, svn_http_server, path):
124 def _get_url(self, svn_http_server, path):
125 svn_http_server_url = (svn_http_server or '').rstrip('/')
125 svn_http_server_url = (svn_http_server or '').rstrip('/')
126 url_path = urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/'))
126 url_path = urllib.parse.urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/'))
127 url_path = urllib.parse.quote(url_path, safe="/:=~+!$,;'")
127 url_path = urllib.parse.quote(url_path, safe="/:=~+!$,;'")
128 return url_path
128 return url_path
129
129
@@ -24,7 +24,7 b' Implementation of the scm_app interface '
24
24
25 import base64
25 import base64
26 import logging
26 import logging
27 import urlparse
27 import urllib.parse
28 import wsgiref.util
28 import wsgiref.util
29
29
30 import msgpack
30 import msgpack
@@ -111,7 +111,7 b' class VcsHttpProxy(object):'
111
111
112 # Preserve the query string
112 # Preserve the query string
113 url = self._url
113 url = self._url
114 url = urlparse.urljoin(url, self._repo_name)
114 url = urllib.parse.urlparse.urljoin(url, self._repo_name)
115 if environ.get('QUERY_STRING'):
115 if environ.get('QUERY_STRING'):
116 url += '?' + environ['QUERY_STRING']
116 url += '?' + environ['QUERY_STRING']
117
117
@@ -22,7 +22,7 b' import gzip'
22 import shutil
22 import shutil
23 import logging
23 import logging
24 import tempfile
24 import tempfile
25 import urlparse
25 import urllib.parse
26
26
27 from webob.exc import HTTPNotFound
27 from webob.exc import HTTPNotFound
28
28
@@ -61,7 +61,7 b' def is_hg(environ):'
61 http_accept = environ.get('HTTP_ACCEPT')
61 http_accept = environ.get('HTTP_ACCEPT')
62
62
63 if http_accept and http_accept.startswith('application/mercurial'):
63 if http_accept and http_accept.startswith('application/mercurial'):
64 query = urlparse.parse_qs(environ['QUERY_STRING'])
64 query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'])
65 if 'cmd' in query:
65 if 'cmd' in query:
66 is_hg_path = True
66 is_hg_path = True
67
67
@@ -27,7 +27,7 b' import logging'
27 import threading
27 import threading
28 import time
28 import time
29 import urllib.request, urllib.error, urllib.parse
29 import urllib.request, urllib.error, urllib.parse
30 import urlparse
30 import urllib.parse
31 import uuid
31 import uuid
32 import traceback
32 import traceback
33
33
@@ -132,7 +132,7 b' def _streaming_remote_call(url, payload,'
132
132
133 class ServiceConnection(object):
133 class ServiceConnection(object):
134 def __init__(self, server_and_port, backend_endpoint, session_factory):
134 def __init__(self, server_and_port, backend_endpoint, session_factory):
135 self.url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
135 self.url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
136 self._session_factory = session_factory
136 self._session_factory = session_factory
137
137
138 def __getattr__(self, name):
138 def __getattr__(self, name):
@@ -154,8 +154,8 b' class ServiceConnection(object):'
154 class RemoteVCSMaker(object):
154 class RemoteVCSMaker(object):
155
155
156 def __init__(self, server_and_port, backend_endpoint, backend_type, session_factory):
156 def __init__(self, server_and_port, backend_endpoint, backend_type, session_factory):
157 self.url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
157 self.url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
158 self.stream_url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint+'/stream')
158 self.stream_url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint+'/stream')
159
159
160 self._session_factory = session_factory
160 self._session_factory = session_factory
161 self.backend_type = backend_type
161 self.backend_type = backend_type
@@ -356,7 +356,7 b' class VcsHttpProxy(object):'
356 retries = Retry(total=5, connect=None, read=None, redirect=None)
356 retries = Retry(total=5, connect=None, read=None, redirect=None)
357
357
358 adapter = requests.adapters.HTTPAdapter(max_retries=retries)
358 adapter = requests.adapters.HTTPAdapter(max_retries=retries)
359 self.base_url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
359 self.base_url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint)
360 self.session = requests.Session()
360 self.session = requests.Session()
361 self.session.mount('http://', adapter)
361 self.session.mount('http://', adapter)
362
362
@@ -21,7 +21,7 b''
21 import logging
21 import logging
22
22
23 import deform.widget
23 import deform.widget
24 from deform.widget import null, OptGroup, string_types
24 from deform.widget import null, OptGroup
25
25
26 log = logging.getLogger(__name__)
26 log = logging.getLogger(__name__)
27
27
@@ -34,7 +34,7 b' def _normalize_choices(values):'
34 result.append(OptGroup(item.label, *normalized_options))
34 result.append(OptGroup(item.label, *normalized_options))
35 else:
35 else:
36 value, description, help_block = item
36 value, description, help_block = item
37 if not isinstance(value, string_types):
37 if not isinstance(value, str):
38 value = str(value)
38 value = str(value)
39 result.append((value, description, help_block))
39 result.append((value, description, help_block))
40 return result
40 return result
@@ -19,7 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import pytest
21 import pytest
22 import urlparse
22 import urllib.parse
23 import mock
23 import mock
24 import simplejson as json
24 import simplejson as json
25
25
@@ -30,7 +30,7 b' import rhodecode.lib.middleware.simplegi'
30
30
31 def get_environ(url, request_method):
31 def get_environ(url, request_method):
32 """Construct a minimum WSGI environ based on the URL."""
32 """Construct a minimum WSGI environ based on the URL."""
33 parsed_url = urlparse.urlparse(url)
33 parsed_url = urllib.parse.urlparse.urlparse(url)
34 environ = {
34 environ = {
35 'PATH_INFO': parsed_url.path,
35 'PATH_INFO': parsed_url.path,
36 'QUERY_STRING': parsed_url.query,
36 'QUERY_STRING': parsed_url.query,
@@ -18,7 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import urlparse
21 import urllib.parse
22
22
23 import mock
23 import mock
24 import pytest
24 import pytest
@@ -31,7 +31,7 b' import rhodecode.lib.middleware.simplehg'
31
31
32 def get_environ(url):
32 def get_environ(url):
33 """Construct a minimum WSGI environ based on the URL."""
33 """Construct a minimum WSGI environ based on the URL."""
34 parsed_url = urlparse.urlparse(url)
34 parsed_url = urllib.parse.urlparse.urlparse(url)
35 environ = {
35 environ = {
36 'PATH_INFO': parsed_url.path,
36 'PATH_INFO': parsed_url.path,
37 'QUERY_STRING': parsed_url.query,
37 'QUERY_STRING': parsed_url.query,
@@ -27,11 +27,11 b' import tempfile'
27 import urllib.request, urllib.error, urllib.parse
27 import urllib.request, urllib.error, urllib.parse
28 from lxml.html import fromstring, tostring
28 from lxml.html import fromstring, tostring
29 from lxml.cssselect import CSSSelector
29 from lxml.cssselect import CSSSelector
30 from urlparse import urlparse, parse_qsl
30 import urllib.parse.urlparse
31 from urllib.parse import unquote_plus
31 from urllib.parse import unquote_plus
32 import webob
32 import webob
33
33
34 from webtest.app import TestResponse, TestApp, string_types
34 from webtest.app import TestResponse, TestApp
35 from webtest.compat import print_stderr
35 from webtest.compat import print_stderr
36
36
37 import pytest
37 import pytest
@@ -67,7 +67,7 b' class CustomTestResponse(TestResponse):'
67 if 'no' in kw:
67 if 'no' in kw:
68 no = kw['no']
68 no = kw['no']
69 del kw['no']
69 del kw['no']
70 if isinstance(no, string_types):
70 if isinstance(no, str):
71 no = [no]
71 no = [no]
72 else:
72 else:
73 no = []
73 no = []
@@ -316,8 +316,8 b' class _Url(object):'
316 """
316 """
317
317
318 def __init__(self, url):
318 def __init__(self, url):
319 parts = urlparse(url)
319 parts = urllib.parse.urlparse(url)
320 _query = frozenset(parse_qsl(parts.query))
320 _query = frozenset(urllib.parse.parse_qsl(parts.query))
321 _path = unquote_plus(parts.path)
321 _path = unquote_plus(parts.path)
322 parts = parts._replace(query=_query, path=_path)
322 parts = parts._replace(query=_query, path=_path)
323 self.parts = parts
323 self.parts = parts
General Comments 0
You need to be logged in to leave comments. Login now