Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit c14f3da

Browse files
committed
More Python3 and pyflakes fixes
1 parent b964317 commit c14f3da

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

documentcloud/MultipartPostHandler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def __init__(self, anycallable):
6262
doseq = 1
6363

6464

65-
class MultipartPostHandler(urllib2.request.BaseHandler):
65+
class MultipartPostHandler(urllib.request.BaseHandler):
6666
# needs to run first
67-
handler_order = urllib2.request.HTTPHandler.handler_order - 10
67+
handler_order = urllib.request.HTTPHandler.handler_order - 10
6868

6969
def http_request(self, request):
7070
data = request.get_data()
@@ -90,7 +90,7 @@ def http_request(self, request):
9090
'multipart/form-data') != 0
9191
):
9292
six.print_(
93-
"Replacing %s with %s" % (
93+
"Replacing %s with %s" % (
9494
request.get_header('content-type'),
9595
'multipart/form-data'
9696
)
@@ -146,7 +146,7 @@ def getsize(o_file):
146146

147147

148148
def main():
149-
opener = urllib2.request.build_opener(MultipartPostHandler)
149+
opener = urllib.request.build_opener(MultipartPostHandler)
150150

151151
def validateFile(url):
152152
temp = tempfile.mkstemp(suffix=".html")

documentcloud/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _make_request(self, url, params=None, opener=None):
5151
"""
5252
# Create the request object
5353
args = [i for i in [url, params] if i]
54-
request = urllib2.request.Request(*args)
54+
request = urllib.request.Request(*args)
5555
# If the client has credentials, include them as a header
5656
if self.username and self.password:
5757
credentials = '%s:%s' % (self.username, self.password)
@@ -63,14 +63,14 @@ def _make_request(self, url, params=None, opener=None):
6363
# If the request provides a custom opener, like the upload request,
6464
# which relies on a multipart request, it is applied here.
6565
if opener:
66-
opener = urllib2.request.build_opener(opener)
66+
opener = urllib.request.build_opener(opener)
6767
request_method = opener.open
6868
else:
69-
request_method = urllib2.request.urlopen
69+
request_method = urllib.request.urlopen
7070
# Make the request
7171
try:
7272
response = request_method(request)
73-
except urllib2.error.HTTPError as e:
73+
except urllib.error.HTTPError as e:
7474
if e.code == 404:
7575
raise DoesNotExistError("The resource you've requested does \
7676
not exist or is unavailable without the proper credentials.")
@@ -693,10 +693,10 @@ def get_entities(self):
693693

694694
def _get_url(self, url):
695695
if self.access == 'public':
696-
req = urllib2.request.Request(url)
696+
req = urllib.request.Request(url)
697697
try:
698-
return urllib2.request.urlopen(req).read()
699-
except urllib2.error.HTTPError:
698+
return urllib.request.urlopen(req).read()
699+
except urllib.error.HTTPError:
700700
raise NotImplementedError(
701701
"Currently, DocumentCloud only allows you to access this \
702702
resource on public documents."

tox.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tox]
2+
envlist=py25,py26,py27,py32,py33
3+
4+
[testenv]
5+
deps=
6+
python-dateutil
7+
simplejson
8+
six
9+
commands=python quicktest.py documentcloud

0 commit comments

Comments
 (0)