Merge lp:~cjwatson/lazr.restful/six-urllib into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 235
Proposed branch: lp:~cjwatson/lazr.restful/six-urllib
Merge into: lp:lazr.restful
Diff against target: 338 lines (+37/-33)
16 files modified
src/lazr/restful/docs/multiversion.rst (+1/-1)
src/lazr/restful/docs/webservice-declarations.rst (+1/-1)
src/lazr/restful/docs/webservice.rst (+2/-3)
src/lazr/restful/example/base/tests/collection.txt (+1/-2)
src/lazr/restful/example/base/tests/entry.txt (+1/-1)
src/lazr/restful/example/base/tests/field.txt (+1/-1)
src/lazr/restful/example/base/tests/hostedfile.txt (+1/-1)
src/lazr/restful/example/base/tests/representation-cache.txt (+1/-1)
src/lazr/restful/example/base/tests/service.txt (+1/-1)
src/lazr/restful/example/base/tests/wadl.txt (+1/-1)
src/lazr/restful/example/base/traversal.py (+1/-1)
src/lazr/restful/marshallers.py (+2/-2)
src/lazr/restful/publisher.py (+8/-7)
src/lazr/restful/simple.py (+6/-4)
src/lazr/restful/tales.py (+2/-2)
src/lazr/restful/testing/webservice.py (+7/-4)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/six-urllib
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
LAZR Developers Pending
Review via email: mp+378515@code.launchpad.net

Commit message

Import urllib and friends from six.moves.

Description of the change

This part of the standard library was rearranged in Python 3.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/docs/multiversion.rst'
2--- src/lazr/restful/docs/multiversion.rst 2020-02-04 11:52:59 +0000
3+++ src/lazr/restful/docs/multiversion.rst 2020-02-04 13:19:13 +0000
4@@ -163,7 +163,7 @@
5
6 Here's a simple implementation of IContact.
7
8- >>> from urllib import quote
9+ >>> from six.moves.urllib.parse import quote
10 >>> from zope.interface import implementer
11 >>> from lazr.restful.security import protect_schema
12 >>> @implementer(IContact, ILocation)
13
14=== modified file 'src/lazr/restful/docs/webservice-declarations.rst'
15--- src/lazr/restful/docs/webservice-declarations.rst 2020-02-04 11:52:59 +0000
16+++ src/lazr/restful/docs/webservice-declarations.rst 2020-02-04 13:19:13 +0000
17@@ -1291,7 +1291,7 @@
18 (For the URL generation to work, we need to register an IAbsoluteURL
19 adapter and set the request as the current interaction.)
20
21- >>> from urllib import quote
22+ >>> from six.moves.urllib.parse import quote
23 >>> from zope.component import provideAdapter
24 >>> from zope.traversing.browser.interfaces import IAbsoluteURL
25 >>> from zope.publisher.interfaces.http import IHTTPApplicationRequest
26
27=== modified file 'src/lazr/restful/docs/webservice.rst'
28--- src/lazr/restful/docs/webservice.rst 2020-02-04 11:52:59 +0000
29+++ src/lazr/restful/docs/webservice.rst 2020-02-04 13:19:13 +0000
30@@ -114,7 +114,7 @@
31 interface.
32
33
34- >>> from urllib import quote
35+ >>> from six.moves.urllib.parse import quote
36 >>> from zope.component import (
37 ... adapter, getSiteManager, getMultiAdapter)
38 >>> from zope.interface import implementer
39@@ -201,7 +201,7 @@
40
41 >>> protect_schema(Cookbook, ICookbook, write_permission=CheckerPublic)
42
43- >>> from urllib import unquote
44+ >>> from six.moves.urllib.parse import unquote
45 >>> @implementer(IPublishTraverse)
46 ... @adapter(ICookbook, IBrowserRequest)
47 ... class CookbookTraversal:
48@@ -2090,7 +2090,6 @@
49 activate that operation and delete the entry by sending a DELETE
50 request.
51
52- >>> from urllib import quote
53 >>> recipe_url = quote('/beta/cookbooks/Mastering the Art of '
54 ... 'French Cooking/recipes/Foies de voilaille en aspic')
55
56
57=== modified file 'src/lazr/restful/example/base/tests/collection.txt'
58--- src/lazr/restful/example/base/tests/collection.txt 2020-02-04 11:52:59 +0000
59+++ src/lazr/restful/example/base/tests/collection.txt 2020-02-04 13:19:13 +0000
60@@ -85,7 +85,7 @@
61
62 A collection may be empty.
63
64- >>> from urllib import quote
65+ >>> from six.moves.urllib.parse import quote
66 >>> url = quote("/cookbooks/Cooking Without Recipes/recipes")
67 >>> result = webservice.get(url)
68 >>> list(result.jsonBody()['entries'])
69@@ -99,7 +99,6 @@
70 them has been marked private. The private one is hidden from view in
71 collections.
72
73- >>> from urllib import quote
74 >>> url = quote("/cookbooks/James Beard's American Cookery/recipes")
75 >>> output = webservice.get(url).jsonBody()
76 >>> output['total_size']
77
78=== modified file 'src/lazr/restful/example/base/tests/entry.txt'
79--- src/lazr/restful/example/base/tests/entry.txt 2020-02-04 11:52:59 +0000
80+++ src/lazr/restful/example/base/tests/entry.txt 2020-02-04 13:19:13 +0000
81@@ -22,7 +22,7 @@
82
83 Here we see that the cookbook 'Everyday Greens' is a vegetarian cookbook.
84
85- >>> from urllib import quote
86+ >>> from six.moves.urllib.parse import quote
87 >>> greens_url = quote("/cookbooks/Everyday Greens")
88 >>> webservice.get(greens_url).jsonBody()['cuisine']
89 u'Vegetarian'
90
91=== modified file 'src/lazr/restful/example/base/tests/field.txt'
92--- src/lazr/restful/example/base/tests/field.txt 2020-02-04 11:52:59 +0000
93+++ src/lazr/restful/example/base/tests/field.txt 2020-02-04 13:19:13 +0000
94@@ -8,7 +8,7 @@
95 >>> from lazr.restful.testing.webservice import WebServiceCaller
96 >>> webservice = WebServiceCaller(domain='cookbooks.dev')
97
98- >>> from urllib import quote
99+ >>> from six.moves.urllib.parse import quote
100 >>> cookbook_url = quote("/cookbooks/The Joy of Cooking")
101 >>> field_url = cookbook_url + "/description"
102
103
104=== modified file 'src/lazr/restful/example/base/tests/hostedfile.txt'
105--- src/lazr/restful/example/base/tests/hostedfile.txt 2020-02-04 11:52:59 +0000
106+++ src/lazr/restful/example/base/tests/hostedfile.txt 2020-02-04 13:19:13 +0000
107@@ -15,7 +15,7 @@
108
109 A cookbook starts out with a link to a cover image, but no actual cover.
110
111- >>> from urllib import quote
112+ >>> from six.moves.urllib.parse import quote
113 >>> greens_url = quote("/cookbooks/Everyday Greens")
114 >>> greens = webservice.get(greens_url).jsonBody()
115 >>> greens['cover_link']
116
117=== modified file 'src/lazr/restful/example/base/tests/representation-cache.txt'
118--- src/lazr/restful/example/base/tests/representation-cache.txt 2020-02-04 11:52:59 +0000
119+++ src/lazr/restful/example/base/tests/representation-cache.txt 2020-02-04 13:19:13 +0000
120@@ -209,7 +209,7 @@
121 >>> print(dictionary.keys()[0])
122 http://.../devel/cookbooks/Everyday%20Greens,application/json
123
124- >>> from urllib import quote
125+ >>> from six.moves.urllib.parse import quote
126 >>> greens_url = quote("/cookbooks/Everyday Greens")
127 >>> ignore = webservice.named_post(
128 ... greens_url, "replace_cover", cover="foo")
129
130=== modified file 'src/lazr/restful/example/base/tests/service.txt'
131--- src/lazr/restful/example/base/tests/service.txt 2020-02-04 11:52:59 +0000
132+++ src/lazr/restful/example/base/tests/service.txt 2020-02-04 13:19:13 +0000
133@@ -59,7 +59,7 @@
134 Allow: GET POST
135 ...
136
137- >>> from urllib import quote
138+ >>> from six.moves.urllib.parse import quote
139 >>> print(webservice.delete(quote("/dishes/Roast chicken")))
140 HTTP/1.1 405 Method Not Allowed...
141 Allow: GET PUT PATCH
142
143=== modified file 'src/lazr/restful/example/base/tests/wadl.txt'
144--- src/lazr/restful/example/base/tests/wadl.txt 2020-02-04 11:52:59 +0000
145+++ src/lazr/restful/example/base/tests/wadl.txt 2020-02-04 13:19:13 +0000
146@@ -12,7 +12,7 @@
147 Let's get a WADL representation of an entry resource (in this case, a
148 cookbook), and see what's inside.
149
150- >>> from urllib import quote
151+ >>> from six.moves.urllib.parse import quote
152 >>> from lazr.restful.testing.webservice import WebServiceCaller
153 >>> webservice = WebServiceCaller(domain='cookbooks.dev')
154 >>> entry_url = quote("/cookbooks/The Joy of Cooking")
155
156=== modified file 'src/lazr/restful/example/base/traversal.py'
157--- src/lazr/restful/example/base/traversal.py 2020-02-04 11:52:59 +0000
158+++ src/lazr/restful/example/base/traversal.py 2020-02-04 13:19:13 +0000
159@@ -13,7 +13,7 @@
160 ]
161
162
163-from urllib import unquote
164+from six.moves.urllib.parse import unquote
165 from zope.publisher.interfaces import IPublishTraverse, NotFound
166 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
167 from zope.traversing.browser import absoluteURL, AbsoluteURL
168
169=== modified file 'src/lazr/restful/marshallers.py'
170--- src/lazr/restful/marshallers.py 2020-02-04 11:52:59 +0000
171+++ src/lazr/restful/marshallers.py 2020-02-04 13:19:13 +0000
172@@ -27,9 +27,9 @@
173 from datetime import datetime
174 import pytz
175 from StringIO import StringIO
176-import urllib
177
178 import simplejson
179+from six.moves.urllib.parse import unquote
180
181 from zope.datetime import (
182 DateTimeError,
183@@ -113,7 +113,7 @@
184 or fragment is not None):
185 raise NotFound(self, url, self.request)
186
187- path_parts = [urllib.unquote(part) for part in path.split('/')]
188+ path_parts = [unquote(part) for part in path.split('/')]
189 path_parts.pop(0)
190 path_parts.reverse()
191 request = config.createRequest(StringIO(), {'PATH_INFO': path})
192
193=== modified file 'src/lazr/restful/publisher.py'
194--- src/lazr/restful/publisher.py 2020-02-04 11:52:59 +0000
195+++ src/lazr/restful/publisher.py 2020-02-04 13:19:13 +0000
196@@ -17,9 +17,11 @@
197
198
199 import simplejson
200-import urllib
201-import urlparse
202-
203+from six.moves.urllib.parse import (
204+ quote,
205+ urlsplit,
206+ urlunsplit,
207+ )
208 from zope.component import (
209 adapter,
210 getMultiAdapter,
211@@ -229,20 +231,19 @@
212 location = request.response.getHeader("Location", None)
213 if location is not None:
214 accept = request.getHeader("Accept", "application/json")
215- qs_append = "ws.accept=" + urllib.quote(accept)
216+ qs_append = "ws.accept=" + quote(accept)
217 # We don't use the URI class because it will raise
218 # an exception if the Location contains invalid
219 # characters. Invalid characters may indeed be a
220 # problem, but let the problem be handled
221 # somewhere else.
222 (scheme, netloc, path, query, fragment) = (
223- urlparse.urlsplit(location))
224+ urlsplit(location))
225 if query == '':
226 query = qs_append
227 else:
228 query += '&' + qs_append
229- uri = urlparse.urlunsplit(
230- (scheme, netloc, path, query, fragment))
231+ uri = urlunsplit((scheme, netloc, path, query, fragment))
232 request.response.setHeader("Location", str(uri))
233 return value
234
235
236=== modified file 'src/lazr/restful/simple.py'
237--- src/lazr/restful/simple.py 2020-02-04 11:52:59 +0000
238+++ src/lazr/restful/simple.py 2020-02-04 13:19:13 +0000
239@@ -19,8 +19,11 @@
240 ]
241
242 import traceback
243-import urllib
244
245+from six.moves.urllib.parse import (
246+ quote,
247+ unquote,
248+ )
249 from zope.component import (
250 adapter, getMultiAdapter, getUtility, queryMultiAdapter)
251 from zope.interface import Attribute, Interface, implementer
252@@ -168,7 +171,7 @@
253
254 def publishTraverse(self, request, name):
255 """See `IPublishTraverse`."""
256- name = urllib.unquote(name)
257+ name = unquote(name)
258 value = self.get(request, name)
259 if value is None:
260 raise NotFound(self, name)
261@@ -370,8 +373,7 @@
262 if not hasattr(parts, '__iter__'):
263 raise TypeError("Expected an iterable for __path_parts__.")
264
265- escaped_parts = [urllib.quote(part.encode('utf-8'), _safe)
266- for part in parts]
267+ escaped_parts = [quote(part.encode('utf-8'), _safe) for part in parts]
268 return start_url + "/" + "/".join(escaped_parts)
269 __call__ = __str__
270
271
272=== modified file 'src/lazr/restful/tales.py'
273--- src/lazr/restful/tales.py 2020-02-04 11:52:59 +0000
274+++ src/lazr/restful/tales.py 2020-02-04 13:19:13 +0000
275@@ -11,7 +11,6 @@
276 import operator
277 import simplejson
278 import textwrap
279-import urllib
280
281 from epydoc.markup import DocstringLinker
282 from epydoc.markup.restructuredtext import (
283@@ -22,6 +21,7 @@
284 from docutils import io
285 from docutils.core import Publisher
286
287+from six.moves.urllib.parse import quote
288 from zope.component import (
289 adapter, getGlobalSiteManager, getUtility, queryMultiAdapter)
290 from zope.interface import implementer
291@@ -246,7 +246,7 @@
292 relationship_name = self.context.relationship.__name__
293 return (absoluteURL(self.context.context,
294 get_current_web_service_request()) + '/' +
295- urllib.quote(relationship_name))
296+ quote(relationship_name))
297 else:
298 return super(WadlCollectionResourceAPI, self).url
299
300
301=== modified file 'src/lazr/restful/testing/webservice.py'
302--- src/lazr/restful/testing/webservice.py 2020-02-04 11:52:59 +0000
303+++ src/lazr/restful/testing/webservice.py 2020-02-04 13:19:13 +0000
304@@ -25,11 +25,14 @@
305 import sys
306 from types import ModuleType
307 import unittest
308-import urllib
309
310-from urlparse import urljoin
311 import wsgi_intercept
312
313+from six.moves.urllib.parse import (
314+ quote,
315+ urlencode,
316+ urljoin,
317+ )
318 from zope.component import (
319 adapter, getGlobalSiteManager, getUtility)
320 from zope.configuration import xmlconfig
321@@ -333,7 +336,7 @@
322 for key, value in args.items():
323 if not isinstance(value, basestring):
324 args[key] = simplejson.dumps(value)
325- return urllib.urlencode(args)
326+ return urlencode(args)
327
328 def named_get(self, path_or_url, operation_name, headers=None,
329 api_version=None, **kwargs):
330@@ -362,7 +365,7 @@
331 """
332 if not isinstance(value, basestring):
333 value = simplejson.dumps(value)
334- return urllib.quote(value)
335+ return quote(value)
336
337 def _make_request_with_entity_body(self, path, method, media_type, data,
338 headers, api_version):

Subscribers

People subscribed via source and target branches