futurize -1
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index 03a3ea7..0c90d70 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -16,6 +16,7 @@
A client library for Google's discovery based APIs.
"""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
__all__ = [
@@ -48,7 +49,7 @@
# Third-party imports
import httplib2
-import mimeparse
+from . import mimeparse
import uritemplate
# Local imports
@@ -329,7 +330,7 @@
The size as an integer value.
"""
if len(maxSize) < 2:
- return 0L
+ return 0
units = maxSize[-2:].upper()
bit_shift = _MEDIA_SIZE_BIT_SHIFTS.get(units)
if bit_shift is not None:
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index d54ce5e..d46e7b1 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -18,6 +18,7 @@
object supporting an execute() method that does the
actuall HTTP request.
"""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -28,7 +29,7 @@
import httplib2
import json
import logging
-import mimeparse
+from . import mimeparse
import mimetypes
import os
import random
@@ -42,13 +43,13 @@
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import FeedParser
-from errors import BatchError
-from errors import HttpError
-from errors import InvalidChunkSizeError
-from errors import ResumableUploadError
-from errors import UnexpectedBodyError
-from errors import UnexpectedMethodError
-from model import JsonModel
+from .errors import BatchError
+from .errors import HttpError
+from .errors import InvalidChunkSizeError
+from .errors import ResumableUploadError
+from .errors import UnexpectedBodyError
+from .errors import UnexpectedMethodError
+from .model import JsonModel
from oauth2client import util
diff --git a/googleapiclient/mimeparse.py b/googleapiclient/mimeparse.py
index 8038af1..68d3a3c 100644
--- a/googleapiclient/mimeparse.py
+++ b/googleapiclient/mimeparse.py
@@ -21,6 +21,7 @@
- best_match(): Choose the mime-type with the highest quality ('q')
from a list of candidates.
"""
+from functools import reduce
__version__ = '0.1.3'
__author__ = 'Joe Gregorio'
@@ -68,7 +69,7 @@
necessary.
"""
(type, subtype, params) = parse_mime_type(range)
- if not params.has_key('q') or not params['q'] or \
+ if 'q' not in params or not params['q'] or \
not float(params['q']) or float(params['q']) > 1\
or float(params['q']) < 0:
params['q'] = '1'
@@ -99,7 +100,7 @@
if type_match and subtype_match:
param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in \
target_params.iteritems() if key != 'q' and \
- params.has_key(key) and value == params[key]], 0)
+ key in params and value == params[key]], 0)
fitness = (type == target_type) and 100 or 0
fitness += (subtype == target_subtype) and 10 or 0
fitness += param_matches
diff --git a/googleapiclient/model.py b/googleapiclient/model.py
index 0f0172c..98e608e 100644
--- a/googleapiclient/model.py
+++ b/googleapiclient/model.py
@@ -21,6 +21,7 @@
for converting between the wire format and the Python
object representation.
"""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -29,7 +30,7 @@
import urllib
from googleapiclient import __version__
-from errors import HttpError
+from .errors import HttpError
dump_request_response = False
diff --git a/samples/coordinate/coordinate.py b/samples/coordinate/coordinate.py
index 00a1f62..61622db 100644
--- a/samples/coordinate/coordinate.py
+++ b/samples/coordinate/coordinate.py
@@ -35,6 +35,7 @@
$ python coordinate.py -t teamId --logging_level=DEBUG
"""
+from __future__ import print_function
__author__ = 'zachn@google.com (Zach Newell)'
diff --git a/samples/django_sample/manage.py b/samples/django_sample/manage.py
index 0b932da..b2f07f1 100755
--- a/samples/django_sample/manage.py
+++ b/samples/django_sample/manage.py
@@ -1,7 +1,8 @@
#!/usr/bin/python
+from __future__ import absolute_import
from django.core.management import execute_manager
try:
- import settings # Assumed to be in the same directory.
+ from . import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("""Error: Can't find the file 'settings.py' in the
diff --git a/samples/urlshortener/urlshortener.py b/samples/urlshortener/urlshortener.py
index 89d1115..00d3bfe 100644
--- a/samples/urlshortener/urlshortener.py
+++ b/samples/urlshortener/urlshortener.py
@@ -32,6 +32,7 @@
$ python urlshortener.py --logging_level=DEBUG
"""
+from __future__ import print_function
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index 032975c..3fdebb2 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -140,7 +140,7 @@
parameters = self._base_fix_up_parameters_test(self.zoo_get_method_desc,
'GET', self.zoo_root_desc)
# Since http_method is 'GET'
- self.assertFalse(parameters.has_key('body'))
+ self.assertFalse('body' in parameters)
def test_fix_up_parameters_insert(self):
parameters = self._base_fix_up_parameters_test(self.zoo_insert_method_desc,
@@ -163,15 +163,15 @@
parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc,
no_payload_http_method)
- self.assertFalse(parameters.has_key('body'))
+ self.assertFalse('body' in parameters)
parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc,
no_payload_http_method)
- self.assertFalse(parameters.has_key('body'))
+ self.assertFalse('body' in parameters)
parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc,
with_payload_http_method)
- self.assertFalse(parameters.has_key('body'))
+ self.assertFalse('body' in parameters)
parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc,
with_payload_http_method)
@@ -251,7 +251,7 @@
http_method = 'GET'
method_id = 'bigquery.query'
accept = []
- max_size = 0L
+ max_size = 0
media_path_url = None
self.assertEqual(result, (path_url, http_method, method_id, accept,
max_size, media_path_url))
@@ -263,7 +263,7 @@
http_method = 'POST'
method_id = 'zoo.animals.insert'
accept = ['image/png']
- max_size = 1024L
+ max_size = 1024
media_path_url = 'https://www.googleapis.com/upload/zoo/v1/animals'
self.assertEqual(result, (path_url, http_method, method_id, accept,
max_size, media_path_url))