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

Commit 8d02776

Browse files
committed
PyFlakes compliance and testing
1 parent 6a4a1e8 commit 8d02776

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ install:
77
- pip install -r requirements.txt --use-mirrors
88
script:
99
- pep8 documentcloud
10+
- pyflakes documentcloud
1011
- python test.py
1112
env:
1213
global:

documentcloud/MultipartPostHandler.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939
The main function of this file is a sample which downloads a page and
4040
then uploads it to the W3C validator.
4141
"""
42+
import os
4243
import sys
43-
import tempfile
4444
import urllib
4545
import urllib2
46+
import tempfile
4647
import mimetools
4748
import mimetypes
48-
import os
49-
import stat
5049
from os import SEEK_END
5150
from cStringIO import StringIO
5251

@@ -106,7 +105,6 @@ def multipart_encode(vars, files, boundary=None, buf=None):
106105
buf.write('Content-Disposition: form-data; name="%s"' % key)
107106
buf.write('\r\n\r\n' + value + '\r\n')
108107
for(key, fd) in files:
109-
file_size = getsize(fd)
110108
try:
111109
filename = fd.name.split('/')[-1]
112110
except AttributeError:
@@ -143,17 +141,11 @@ def getsize(o_file):
143141

144142

145143
def main():
146-
validatorURL = "http://validator.w3.org/check"
147144
opener = urllib2.build_opener(MultipartPostHandler)
148145

149146
def validateFile(url):
150147
temp = tempfile.mkstemp(suffix=".html")
151148
os.write(temp[0], opener.open(url).read())
152-
params = {
153-
"ss": "0", # show source
154-
"doctype": "Inline",
155-
"uploaded_file": open(temp[1], "rb")
156-
}
157149
os.remove(temp[1])
158150

159151
if len(sys.argv[1:]) > 0:

documentcloud/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import base64
1717
import urllib
1818
import urllib2
19-
from datetime import datetime
20-
from toolbox import *
19+
from toolbox import retry
20+
from toolbox import DoesNotExistError
21+
from toolbox import DuplicateObjectError
22+
from toolbox import credentials_required
23+
from toolbox import CredentialsFailedError
2124
from dateutil.parser import parse as dateparser
2225
from MultipartPostHandler import MultipartPostHandler
2326
try:
@@ -115,7 +118,7 @@ def put(self, method, params):
115118
# Otherwise, we can just use the vanilla urllib prep method
116119
params = urllib.urlencode(params, doseq=True)
117120
# Make the request
118-
content = self._make_request(
121+
self._make_request(
119122
self.BASE_URI + method,
120123
params,
121124
)
@@ -320,7 +323,7 @@ def delete(self, id):
320323
"""
321324
Deletes a Document.
322325
"""
323-
data = self.fetch(
326+
self.fetch(
324327
'documents/%s.json' % id,
325328
{'_method': 'delete'},
326329
)
@@ -462,7 +465,7 @@ def delete(self, id):
462465
"""
463466
Deletes a Project.
464467
"""
465-
data = self.fetch(
468+
self.fetch(
466469
'projects/%s.json' % id,
467470
{'_method': 'delete'},
468471
)

documentcloud/toolbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def f_retry(*args, **kwargs):
7373
return f(*args, **kwargs)
7474
try_one_last_time = False
7575
break
76-
except ExceptionToCheck, e:
76+
except ExceptionToCheck:
7777
print "Retrying in %s seconds" % str(mdelay)
7878
time.sleep(mdelay)
7979
mtries -= 1

0 commit comments

Comments
 (0)