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

Commit 829a318

Browse files
committed
More Python3 changes
1 parent 331dfcd commit 829a318

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
language: python
22
python:
3-
- '2.5'
4-
- '2.6'
5-
- '2.7'
63
- '3.3'
74
install:
85
- pip install -r requirements.txt --use-mirrors

documentcloud/MultipartPostHandler.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@
4343
import sys
4444
import six
4545
import tempfile
46-
import mimetools
4746
import mimetypes
4847
from os import SEEK_END
49-
from six.moves import urllib
50-
try:
51-
import cStringIO as io
52-
except ImportError:
48+
if six.PY3:
5349
import io
54-
50+
import urllib
51+
from email.generator import _make_boundary as choose_boundary
52+
else:
53+
import cStringIO as io
54+
from six.moves import urllib
55+
from mimetools import choose_boundary
5556

5657
class Callable:
5758
def __init__(self, anycallable):
@@ -102,7 +103,7 @@ def http_request(self, request):
102103

103104
def multipart_encode(vars, files, boundary=None, buf=None):
104105
if boundary is None:
105-
boundary = mimetools.choose_boundary()
106+
boundary = choose_boundary()
106107
if buf is None:
107108
buf = io.StringIO()
108109
for(key, value) in vars:

documentcloud/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
import copy
1919
import base64
2020
from .toolbox import retry
21-
from six.moves import urllib
2221
from .toolbox import DoesNotExistError
2322
from .toolbox import DuplicateObjectError
2423
from .toolbox import credentials_required
2524
from .toolbox import CredentialsFailedError
2625
from dateutil.parser import parse as dateparser
2726
from .MultipartPostHandler import MultipartPostHandler
27+
if six.PY3:
28+
import urllib
29+
else:
30+
from six.moves import urllib
2831
try:
2932
import json
3033
except ImportError:

0 commit comments

Comments
 (0)