Skip to content

Commit cff060c

Browse files
committed
Fix all lint errors
1 parent f9cf390 commit cff060c

File tree

22 files changed

+247
-202
lines changed

22 files changed

+247
-202
lines changed

admin_sdk/directory/quickstart.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
from __future__ import print_function
2121
from apiclient.discovery import build
2222
from httplib2 import Http
23-
from oauth2client import file, client, tools
23+
from oauth2client import file as oauth_file, client, tools
2424

2525
# Setup the Admin SDK Directory API
2626
SCOPES = 'https://www.googleapis.com/auth/admin.directory.user'
27-
store = file.Storage('token.json')
27+
store = oauth_file.Storage('token.json')
2828
creds = store.get()
2929
if not creds or creds.invalid:
3030
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
@@ -42,5 +42,6 @@
4242
else:
4343
print('Users:')
4444
for user in users:
45-
print('{0} ({1})'.format(user['primaryEmail'], user['name']['fullName']))
45+
print('{0} ({1})'.format(user['primaryEmail'],
46+
user['name']['fullName']))
4647
# [END admin_sdk_directory_quickstart]

admin_sdk/reports/quickstart.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
events.
1919
"""
2020
from __future__ import print_function
21-
from apiclient.discovery import build, http
21+
from apiclient.discovery import build
2222
from httplib2 import Http
23-
from oauth2client import file, client, tools
24-
import StringIO
25-
import random
26-
27-
import apiclient
28-
from email import Utils
29-
from email import MIMEText
23+
from oauth2client import file as oauth_file, client, tools
3024

3125
# Setup the Admin SDK Reports API
3226
SCOPES = 'https://www.googleapis.com/auth/admin.reports.audit.readonly'
33-
store = file.Storage('token.json')
27+
store = oauth_file.Storage('token.json')
3428
creds = store.get()
3529
if not creds or creds.invalid:
3630
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

admin_sdk/reseller/quickstart.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
events.
1919
"""
2020
from __future__ import print_function
21-
from apiclient.discovery import build, http
21+
from apiclient.discovery import build
2222
from httplib2 import Http
23-
from oauth2client import file, client, tools
24-
import StringIO
25-
import random
26-
27-
import apiclient
28-
from email import Utils
29-
from email import MIMEText
23+
from oauth2client import file as oauth_file, client, tools
3024

3125
# Setup the Admin SDK Reports API
3226
SCOPES = 'https://www.googleapis.com/auth/admin.reports.audit.readonly'
33-
store = file.Storage('token.json')
27+
store = oauth_file.Storage('token.json')
3428
creds = store.get()
3529
if not creds or creds.invalid:
3630
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

apps_script/execute/execute.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
# limitations under the License.
1414

1515
# [START apps_script_execute]
16+
from __future__ import print_function
17+
from apiclient import errors
18+
from apiclient.discovery import build
19+
from httplib2 import Http
20+
from oauth2client import file as oauthfile, client, tools
21+
1622
def main():
1723
"""Shows basic usage of the Apps Script API.
1824
@@ -22,10 +28,14 @@ def main():
2228
"""
2329
SCRIPT_ID = 'ENTER_YOUR_SCRIPT_ID_HERE'
2430

25-
# Authorize and create a service object.
26-
credentials = get_credentials()
27-
http = credentials.authorize(httplib2.Http())
28-
service = discovery.build('script', 'v1', http=http)
31+
# Setup the Apps Script API
32+
SCOPES = 'https://www.googleapis.com/auth/script.projects'
33+
store = oauthfile.Storage('token.json')
34+
creds = store.get()
35+
if not creds or creds.invalid:
36+
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
37+
creds = tools.run_flow(flow, store)
38+
service = build('script', 'v1', http=creds.authorize(Http()))
2939

3040
# Create an execution request object.
3141
request = {"function": "getFoldersUnderRoot"}

apps_script/quickstart/quickstart.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
from apiclient import errors
2323
from apiclient.discovery import build
2424
from httplib2 import Http
25-
from oauth2client import file, client, tools
25+
from oauth2client import file as oauthfile, client, tools
2626

2727
# Setup the Apps Script API
2828
SCOPES = 'https://www.googleapis.com/auth/script.projects'
29-
store = file.Storage('token.json')
29+
store = oauthfile.Storage('token.json')
3030
creds = store.get()
3131
if not creds or creds.invalid:
3232
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
@@ -35,27 +35,28 @@
3535

3636
# Call the Apps Script API
3737
try:
38-
# Create a new project
39-
request = {'title2': 'My Script'}
40-
response = service.projects().create(body=request).execute()
38+
# Create a new project
39+
request = {'title2': 'My Script'}
40+
response = service.projects().create(body=request).execute()
4141

42-
# Upload two files to the project
43-
request = {
44-
'files': [{
45-
'name': 'hello',
46-
'type': 'SERVER_JS',
47-
'source': 'function helloWorld() {\n console.log("Hello, world!");\n}'
48-
}, {
49-
'name': 'appsscript',
50-
'type': 'JSON',
51-
'source': '{\"timeZone\":\"America/New_York\",\"exceptionLogging\":' + \
52-
'\"CLOUD\"}'
53-
}]
54-
}
55-
response = service.projects().updateContent(body=request,
42+
# Upload two files to the project
43+
request = {
44+
'files': [{
45+
'name': 'hello',
46+
'type': 'SERVER_JS',
47+
'source': 'function helloWorld() {\n ' \
48+
'console.log("Hello, world!");\n}'
49+
}, {
50+
'name': 'appsscript',
51+
'type': 'JSON',
52+
'source': '{\"timeZone\":\"America/New_York\",' \
53+
'\"exceptionLogging\":\"CLOUD\"}'
54+
}]
55+
}
56+
response = service.projects().updateContent(body=request,
5657
scriptId=response['scriptId']).execute()
57-
print('https://script.google.com/d/' + response['scriptId'] + '/edit')
58+
print('https://script.google.com/d/' + response['scriptId'] + '/edit')
5859
except errors.HttpError as e:
59-
# The API encountered a problem.
60-
print(e.content)
60+
# The API encountered a problem.
61+
print(e.content)
6162
# [END apps_script_quickstart]

calendar/quickstart/quickstart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
service object and outputs a list of the next 10 events on the user's calendar.
1919
"""
2020
from __future__ import print_function
21+
import datetime
2122
from apiclient.discovery import build
2223
from httplib2 import Http
23-
from oauth2client import file, client, tools
24-
import datetime
24+
from oauth2client import file as oauth_file, client, tools
2525

2626
# Setup the Calendar API
2727
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
28-
store = file.Storage('token.json')
28+
store = oauth_file.Storage('token.json')
2929
creds = store.get()
3030
if not creds or creds.invalid:
3131
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

classroom/quickstart/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
from __future__ import print_function
2323
from apiclient.discovery import build
2424
from httplib2 import Http
25-
from oauth2client import file, client, tools
25+
from oauth2client import file as oauth_file, client, tools
2626

2727
# Setup the Classroom API
2828
SCOPES = 'https://www.googleapis.com/auth/classroom.courses.readonly'
29-
store = file.Storage('token.json')
29+
store = oauth_file.Storage('token.json')
3030
creds = store.get()
3131
if not creds or creds.invalid:
3232
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

drive/activity/quickstart.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414

1515
# [START drive_activity_quickstart]
1616
from __future__ import print_function
17+
import datetime
1718
from apiclient.discovery import build
1819
from httplib2 import Http
19-
from oauth2client import file, client, tools
20-
import datetime
20+
from oauth2client import file as oauth_file, client, tools
2121

2222
# Setup the Drive Activity API
23-
SCOPES = 'https://www.googleapis.com/auth/activity https://www.googleapis.com/auth/drive.metadata.readonly'
24-
store = file.Storage('token.json')
23+
SCOPES = [
24+
'https://www.googleapis.com/auth/activity',
25+
'https://www.googleapis.com/auth/drive.metadata.readonly'
26+
]
27+
store = oauth_file.Storage('token.json')
2528
creds = store.get()
2629
if not creds or creds.invalid:
2730
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
@@ -40,7 +43,7 @@
4043
event = activity['combinedEvent']
4144
user = event.get('user', None)
4245
target = event.get('target', None)
43-
if user == None or target == None:
46+
if user is None or target is None:
4447
continue
4548
time = datetime.datetime.fromtimestamp(
4649
int(event['eventTimeMillis'])/1000)

drive/driveapp/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
import pprint
9-
109
import httplib2
1110
import apiclient.discovery
1211
import apiclient.http
@@ -54,5 +53,6 @@
5453
}
5554

5655
# Perform the request and print the result.
57-
new_file = drive_service.files().insert(body=body, media_body=media_body).execute()
56+
new_file = drive_service.files().insert(
57+
body=body, media_body=media_body).execute()
5858
pprint.pprint(new_file)

drive/quickstart/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
from __future__ import print_function
2323
from apiclient.discovery import build
2424
from httplib2 import Http
25-
from oauth2client import file, client, tools
25+
from oauth2client import file as oauth_file, client, tools
2626

2727
# Setup the Drive v3 API
2828
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
29-
store = file.Storage('token.json')
29+
store = oauth_file.Storage('token.json')
3030
creds = store.get()
3131
if not creds or creds.invalid:
3232
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

0 commit comments

Comments
 (0)