Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6755f61

Browse files
author
Jon Wayne Parrott
authored
Add support for oauth2client >= 3.0.0, < 4.0.0. (googleapis#265)
1 parent 4859b14 commit 6755f61

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

googleapiclient/channel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464
from oauth2client import util
6565
import six
6666

67+
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
68+
# in '_helpers'.
69+
try:
70+
from oauth2client import util
71+
except ImportError:
72+
from oauth2client import _helpers as util
73+
6774

6875
# The unix time epoch starts at midnight 1970.
6976
EPOCH = datetime.datetime.utcfromtimestamp(0)

googleapiclient/discovery.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@
6969
from googleapiclient.model import RawModel
7070
from googleapiclient.schema import Schemas
7171
from oauth2client.client import GoogleCredentials
72-
from oauth2client.util import _add_query_parameter
73-
from oauth2client.util import positional
72+
73+
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
74+
# in '_helpers'.
75+
try:
76+
from oauth2client.util import _add_query_parameter
77+
from oauth2client.util import positional
78+
except ImportError:
79+
from oauth2client._helpers import _add_query_parameter
80+
from oauth2client._helpers import positional
7481

7582

7683
# The client library requires a version of httplib2 that supports RETRIES.

googleapiclient/errors.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323

2424
import json
2525

26-
from oauth2client import util
26+
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
27+
# in '_helpers'.
28+
try:
29+
from oauth2client import util
30+
except ImportError:
31+
from oauth2client import _helpers as util
2732

2833

2934
class Error(Exception):

googleapiclient/http.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@
5555
from email.mime.nonmultipart import MIMENonMultipart
5656
from email.parser import FeedParser
5757

58+
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
59+
# in '_helpers'.
60+
try:
61+
from oauth2client import util
62+
except ImportError:
63+
from oauth2client import _helpers as util
64+
5865
from googleapiclient import mimeparse
5966
from googleapiclient.errors import BatchError
6067
from googleapiclient.errors import HttpError
@@ -63,7 +70,6 @@
6370
from googleapiclient.errors import UnexpectedBodyError
6471
from googleapiclient.errors import UnexpectedMethodError
6572
from googleapiclient.model import JsonModel
66-
from oauth2client import util
6773

6874

6975
LOGGER = logging.getLogger(__name__)

googleapiclient/schema.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@
6565

6666
import copy
6767

68-
from oauth2client import util
68+
# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
69+
# in '_helpers'.
70+
try:
71+
from oauth2client import util
72+
except ImportError:
73+
from oauth2client import _helpers as util
6974

7075

7176
class Schemas(object):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _DetectBadness():
6464

6565
install_requires = [
6666
'httplib2>=0.8,<1',
67-
'oauth2client',
67+
'oauth2client>=1.5.0,<4.0.0',
6868
'six>=1.6.1,<2',
6969
'uritemplate>=0.6,<1',
7070
]

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[tox]
2-
envlist = py{26,27,33,34}-oauth2client{1,2}
2+
envlist = py{26,27,33,34}-oauth2client{1,2,3}
33

44
[testenv]
55
deps =
66
oauth2client1: oauth2client<2
77
oauth2client2: oauth2client>=2,<=3
8+
oauth2client3: oauth2client>=3,<=4
89
keyring
910
mox
1011
pyopenssl

0 commit comments

Comments
 (0)