Skip to content

Commit

Permalink
Add support for oauth2client >= 3.0.0, < 4.0.0. (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored Aug 15, 2016
1 parent 4859b14 commit 6755f61
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 7 deletions.
7 changes: 7 additions & 0 deletions googleapiclient/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
from oauth2client import util
import six

# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
# in '_helpers'.
try:
from oauth2client import util
except ImportError:
from oauth2client import _helpers as util


# The unix time epoch starts at midnight 1970.
EPOCH = datetime.datetime.utcfromtimestamp(0)
Expand Down
11 changes: 9 additions & 2 deletions googleapiclient/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@
from googleapiclient.model import RawModel
from googleapiclient.schema import Schemas
from oauth2client.client import GoogleCredentials
from oauth2client.util import _add_query_parameter
from oauth2client.util import positional

# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
# in '_helpers'.
try:
from oauth2client.util import _add_query_parameter
from oauth2client.util import positional
except ImportError:
from oauth2client._helpers import _add_query_parameter
from oauth2client._helpers import positional


# The client library requires a version of httplib2 that supports RETRIES.
Expand Down
7 changes: 6 additions & 1 deletion googleapiclient/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@

import json

from oauth2client import util
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
# in '_helpers'.
try:
from oauth2client import util
except ImportError:
from oauth2client import _helpers as util


class Error(Exception):
Expand Down
8 changes: 7 additions & 1 deletion googleapiclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import FeedParser

# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
# in '_helpers'.
try:
from oauth2client import util
except ImportError:
from oauth2client import _helpers as util

from googleapiclient import mimeparse
from googleapiclient.errors import BatchError
from googleapiclient.errors import HttpError
Expand All @@ -63,7 +70,6 @@
from googleapiclient.errors import UnexpectedBodyError
from googleapiclient.errors import UnexpectedMethodError
from googleapiclient.model import JsonModel
from oauth2client import util


LOGGER = logging.getLogger(__name__)
Expand Down
7 changes: 6 additions & 1 deletion googleapiclient/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@

import copy

from oauth2client import util
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
# in '_helpers'.
try:
from oauth2client import util
except ImportError:
from oauth2client import _helpers as util


class Schemas(object):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _DetectBadness():

install_requires = [
'httplib2>=0.8,<1',
'oauth2client',
'oauth2client>=1.5.0,<4.0.0',
'six>=1.6.1,<2',
'uritemplate>=0.6,<1',
]
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[tox]
envlist = py{26,27,33,34}-oauth2client{1,2}
envlist = py{26,27,33,34}-oauth2client{1,2,3}

[testenv]
deps =
oauth2client1: oauth2client<2
oauth2client2: oauth2client>=2,<=3
oauth2client3: oauth2client>=3,<=4
keyring
mox
pyopenssl
Expand Down

0 comments on commit 6755f61

Please sign in to comment.