Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit f159854

Browse files
committed
future: stage 2
1 parent c6ef83c commit f159854

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

pypodio2/areas.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# -*- coding: utf-8 -*-
2+
from future import standard_library
3+
standard_library.install_aliases()
4+
from builtins import str
5+
from builtins import object
26
import json
37

48
try:
59
from urllib.parse import urlencode
610
except ImportError:
7-
from urllib import urlencode
11+
from urllib.parse import urlencode
812

913

1014
class Area(object):

pypodio2/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
from builtins import object
34
from . import areas
45

56

pypodio2/encode.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
66
multipart/form-data is the standard way to upload files over HTTP"""
77

8+
from past.builtins import cmp
9+
from future import standard_library
10+
standard_library.install_aliases()
11+
from builtins import next
12+
from builtins import str
13+
from builtins import object
814
import mimetypes
915
import os
1016
import re
11-
import urllib
17+
import urllib.request, urllib.parse, urllib.error
1218
from email.header import Header
1319

1420
__all__ = ['gen_boundary', 'encode_and_quote', 'MultipartParam',
@@ -44,17 +50,17 @@ def encode_and_quote(data):
4450
if data is None:
4551
return None
4652

47-
if isinstance(data, unicode):
53+
if isinstance(data, str):
4854
data = data.encode("utf-8")
49-
return urllib.quote_plus(data)
55+
return urllib.parse.quote_plus(data)
5056

5157

5258
def _strify(s):
5359
"""If s is a unicode string, encode it to UTF-8 and return the results,
5460
otherwise return str(s), or None if s is None"""
5561
if s is None:
5662
return None
57-
if isinstance(s, unicode):
63+
if isinstance(s, str):
5864
return s.encode("utf-8")
5965
return str(s)
6066

@@ -99,7 +105,7 @@ def __init__(self, name, value=None, filename=None, filetype=None,
99105
if filename is None:
100106
self.filename = None
101107
else:
102-
if isinstance(filename, unicode):
108+
if isinstance(filename, str):
103109
# Encode with XML entities
104110
self.filename = filename.encode("ascii", "xmlcharrefreplace")
105111
else:
@@ -166,7 +172,7 @@ def from_params(cls, params):
166172
MultipartParam object names must match the given names in the
167173
name,value pairs or mapping, if applicable."""
168174
if hasattr(params, 'items'):
169-
params = params.items()
175+
params = list(params.items())
170176

171177
retval = []
172178
for item in params:
@@ -323,13 +329,13 @@ def get_headers(params, boundary):
323329
"""Returns a dictionary with Content-Type and Content-Length headers
324330
for the multipart/form-data encoding of ``params``."""
325331
headers = {}
326-
boundary = urllib.quote_plus(boundary)
332+
boundary = urllib.parse.quote_plus(boundary)
327333
headers['Content-Type'] = "multipart/form-data; boundary=%s" % boundary
328334
headers['Content-Length'] = str(get_body_size(params, boundary))
329335
return headers
330336

331337

332-
class MultipartYielder:
338+
class MultipartYielder(object):
333339
def __init__(self, params, boundary, cb):
334340
self.params = params
335341
self.boundary = boundary
@@ -344,7 +350,7 @@ def __init__(self, params, boundary, cb):
344350
def __iter__(self):
345351
return self
346352

347-
def next(self):
353+
def __next__(self):
348354
"""generator function to yield multipart/form-data representation
349355
of parameters"""
350356
if self.param_iter is not None:
@@ -425,7 +431,7 @@ def multipart_encode(params, boundary=None, cb=None):
425431
if boundary is None:
426432
boundary = gen_boundary()
427433
else:
428-
boundary = urllib.quote_plus(boundary)
434+
boundary = urllib.parse.quote_plus(boundary)
429435

430436
headers = get_headers(params, boundary)
431437
params = MultipartParam.from_params(params)

pypodio2/transport.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# -*- coding: utf-8 -*-
2+
from future import standard_library
3+
standard_library.install_aliases()
4+
from builtins import str
5+
from builtins import object
26
from httplib2 import Http
37

48
try:
59
from urllib.parse import urlencode
610
except ImportError:
7-
from urllib import urlencode
11+
from urllib.parse import urlencode
812

913
from .encode import multipart_encode
1014

0 commit comments

Comments
 (0)