Skip to content

Commit 291ba9a

Browse files
committed
fix lint errors
1 parent aef1b13 commit 291ba9a

File tree

5 files changed

+125
-110
lines changed

5 files changed

+125
-110
lines changed

events/next18/customer_data_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"""
2222

2323

24-
class CustomerDataService(object):
24+
class CustomerDataService:
2525
_CUSTOMER_DATA = {
2626
'mars': {
2727
'customer_name': 'Mars Inc.',

events/next18/customer_spreadsheet_reader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import collections
2020

2121

22-
class CustomerSpreadsheetReader(object):
22+
class CustomerSpreadsheetReader:
2323

2424
def __init__(self, sheets_service, spreadsheet_id):
2525
self._sheets_service = sheets_service
@@ -49,7 +49,7 @@ def ExecuteRead(self):
4949
return customer_spreadsheet
5050

5151

52-
class CustomerSpreadsheet(object):
52+
class CustomerSpreadsheet:
5353

5454
def __init__(self, spreadsheet, data_filters):
5555
self._spreadsheet = spreadsheet

events/next18/presentation_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import re
2323

2424

25-
class PresentationReader(object):
25+
class PresentationReader:
2626

2727
def __init__(self, slides_service, presentation_id):
2828
self._slides_service = slides_service

events/next18/presentation_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"""
1919

2020

21-
class PresentationWriter(object):
21+
class PresentationWriter:
2222
"""Queues writes for modifying a presentation.
2323
2424
Call ExecuteBatchUpdate to flush pending writes.
Lines changed: 120 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,139 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# pylint: disable=E1102
116
# python3
217
"""Functionality for creating and writing to a spreadsheet."""
318

419

520
def CreateSpreadsheet(sheets_service, title, sheet_titles):
6-
"""Creates an empty spreadsheet.
7-
8-
It creates a spreadsheet with the provided title, and creates a sheet for
9-
each entry in the sheet_titles list with the corresponding sheet title.
10-
"""
11-
sheets = []
12-
for sheet_title in sheet_titles:
13-
sheet = {
21+
"""Creates an empty spreadsheet.
22+
23+
It creates a spreadsheet with the provided title, and creates a sheet for
24+
each entry in the sheet_titles list with the corresponding sheet title.
25+
"""
26+
sheets = []
27+
for sheet_title in sheet_titles:
28+
sheet = {
29+
'properties': {
30+
'title': sheet_title,
31+
},
32+
}
33+
sheets.append(sheet)
34+
35+
spreadsheet = {
1436
'properties': {
15-
'title': sheet_title,
37+
'title': title,
1638
},
39+
'sheets': sheets,
1740
}
18-
sheets.append(sheet)
19-
20-
spreadsheet = {
21-
'properties': {
22-
'title': title,
23-
},
24-
'sheets': sheets,
25-
}
26-
return sheets_service.spreadsheets().create(body=spreadsheet).execute()
41+
return sheets_service.spreadsheets().create(body=spreadsheet).execute()
2742

2843

2944
class SpreadsheetWriter:
30-
"""Queues writes for modifying a spreadsheet.
31-
32-
Call ExecuteBatchUpdate to flush pending writes.
33-
"""
34-
35-
def __init__(self, sheets_service, spreadsheet_id):
36-
self._sheets_service = sheets_service
37-
self._spreadsheet_id = spreadsheet_id
38-
self._requests = []
39-
40-
def InsertColumn(self, sheet_id, column_index):
41-
request = {
42-
'insertDimension': {
43-
'range': {
44-
'sheetId': sheet_id,
45-
'dimension': 'COLUMNS',
46-
'startIndex': column_index,
47-
'endIndex': column_index + 1,
48-
},
49-
}
50-
}
51-
self._requests.append(request)
52-
53-
def PopulateColumn(self, sheet_id, column_index, column_id, values):
54-
# Include the column ID in the column values
55-
values = [column_id] + values
56-
57-
# Populate the column with the values
58-
rows = []
59-
for value in values:
60-
row_data = {
61-
'values': [
62-
{
63-
'userEnteredValue': {
64-
'stringValue': value
45+
"""Queues writes for modifying a spreadsheet.
46+
47+
Call ExecuteBatchUpdate to flush pending writes.
48+
"""
49+
50+
def __init__(self, sheets_service, spreadsheet_id):
51+
self._sheets_service = sheets_service
52+
self._spreadsheet_id = spreadsheet_id
53+
self._requests = []
54+
55+
def InsertColumn(self, sheet_id, column_index):
56+
request = {
57+
'insertDimension': {
58+
'range': {
59+
'sheetId': sheet_id,
60+
'dimension': 'COLUMNS',
61+
'startIndex': column_index,
62+
'endIndex': column_index + 1,
63+
},
64+
}
65+
}
66+
self._requests.append(request)
67+
68+
def PopulateColumn(self, sheet_id, column_index, column_id, values):
69+
# Include the column ID in the column values
70+
values = [column_id] + values
71+
72+
# Populate the column with the values
73+
rows = []
74+
for value in values:
75+
row_data = {
76+
'values': [
77+
{
78+
'userEnteredValue': {
79+
'stringValue': value
80+
}
6581
}
66-
}
67-
]
68-
}
69-
rows.append(row_data)
70-
71-
update_request = {
72-
'updateCells': {
73-
'rows': rows,
74-
'fields': 'userEnteredValue',
75-
'start': {
76-
'sheetId': sheet_id,
77-
'rowIndex': 0,
78-
'columnIndex': column_index
82+
]
83+
}
84+
rows.append(row_data)
85+
86+
update_request = {
87+
'updateCells': {
88+
'rows': rows,
89+
'fields': 'userEnteredValue',
90+
'start': {
91+
'sheetId': sheet_id,
92+
'rowIndex': 0,
93+
'columnIndex': column_index
94+
}
7995
}
8096
}
81-
}
82-
self._requests.append(update_request)
83-
84-
# Add developer metadata to the column to make it easier to read later by
85-
# being able to just query it by the column ID
86-
metadata_request = {
87-
'createDeveloperMetadata': {
88-
'developerMetadata': {
89-
'metadataKey': 'column_id',
90-
'metadataValue': column_id,
91-
'location': {
92-
'dimensionRange': {
93-
'sheetId': sheet_id,
94-
'dimension': 'COLUMNS',
95-
'startIndex': column_index,
96-
'endIndex': column_index + 1,
97-
}
98-
},
99-
'visibility': 'DOCUMENT',
97+
self._requests.append(update_request)
98+
99+
# Add developer metadata to the column to make it easier to read later
100+
# by being able to just query it by the column ID
101+
metadata_request = {
102+
'createDeveloperMetadata': {
103+
'developerMetadata': {
104+
'metadataKey': 'column_id',
105+
'metadataValue': column_id,
106+
'location': {
107+
'dimensionRange': {
108+
'sheetId': sheet_id,
109+
'dimension': 'COLUMNS',
110+
'startIndex': column_index,
111+
'endIndex': column_index + 1,
112+
}
113+
},
114+
'visibility': 'DOCUMENT',
115+
}
100116
}
101117
}
102-
}
103-
self._requests.append(metadata_request)
104-
105-
def AddTemplateIdToSpreadsheetMetadata(self, template_id):
106-
request = {
107-
'createDeveloperMetadata': {
108-
'developerMetadata': {
109-
'metadataKey': 'template_id',
110-
'metadataValue': template_id,
111-
'location': {
112-
'spreadsheet': True
113-
},
114-
'visibility': 'DOCUMENT',
118+
self._requests.append(metadata_request)
119+
120+
def AddTemplateIdToSpreadsheetMetadata(self, template_id):
121+
request = {
122+
'createDeveloperMetadata': {
123+
'developerMetadata': {
124+
'metadataKey': 'template_id',
125+
'metadataValue': template_id,
126+
'location': {
127+
'spreadsheet': True
128+
},
129+
'visibility': 'DOCUMENT',
130+
}
115131
}
116132
}
117-
}
118-
self._requests.append(request)
133+
self._requests.append(request)
119134

120-
def ExecuteBatchUpdate(self):
121-
body = {'requests': self._requests}
122-
self._requests = []
123-
return self._sheets_service.spreadsheets().batchUpdate(
124-
spreadsheetId=self._spreadsheet_id, body=body).execute()
135+
def ExecuteBatchUpdate(self):
136+
body = {'requests': self._requests}
137+
self._requests = []
138+
return self._sheets_service.spreadsheets().batchUpdate(
139+
spreadsheetId=self._spreadsheet_id, body=body).execute()

0 commit comments

Comments
 (0)