Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1cd768d

Browse filesBrowse files
committed
made rows and cells Block properties instead of methods
1 parent f10b3ec commit 1cd768d
Copy full SHA for 1cd768d

File tree

Expand file treeCollapse file tree

4 files changed

+42
-26
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+42
-26
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Currently supports Python 2.7 :snake::snake::snake:
1010
## Usage
1111
Requires a valid Google API Credentials object from Google's excellent oauth2lib library. For more information, visit [here](https://developers.google.com/identity/protocols/OAuth2).
1212

13-
### Google Drive
13+
### Google Drive v3
1414

1515
- [x] Retrieve drive 'About' information:
1616

@@ -62,7 +62,7 @@ Requires a valid Google API Credentials object from Google's excellent oauth2lib
6262
print permission.role, permission.type, permission.email
6363
```
6464

65-
### Google Slides
65+
### Google Slides v1
6666

6767
- [x] Retrieve presentation and loop through elements:
6868

@@ -105,7 +105,7 @@ Requires a valid Google API Credentials object from Google's excellent oauth2lib
105105

106106
```
107107

108-
### Google Sheets
108+
### Google Sheets v4
109109

110110
- [x] Retrieve spreadsheet and loop through sheets:
111111

‎google_objects/sheets.py

Copy file name to clipboardExpand all lines: google_objects/sheets.py
+39-11Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# ii/ page title and descriptor need to be found and initialized
2323
# iii/ change .from_existing to .from_raw
2424

25+
def grid_to_a1():
2526

2627
class SheetsAPI(GoogleAPI):
2728

@@ -78,14 +79,10 @@ def append_values(self, spreadsheet_id, rng, values):
7879
def push_updates(self, spreadsheet_id, updates):
7980
spreadsheets = self._resource.spreadsheets()
8081
spreadsheets.batchUpdate(
81-
presentationId=spreadsheet_id,
82+
spreadsheetId=spreadsheet_id,
8283
body={'requests': updates}
83-
)
84-
spreadsheets.execute()
85-
86-
87-
88-
# objects
84+
).execute()
85+
# spreadsheets.execute()
8986

9087

9188
class Spreadsheet(GoogleObject):
@@ -133,7 +130,7 @@ def title(self, value):
133130
self._properties['title'] = value
134131

135132
def sheets(self):
136-
return [ sheet for sheet in self.yield_sheets() ]
133+
return [sheet for sheet in self.yield_sheets()]
137134

138135
def yield_sheets(self):
139136
for sheet in self._sheets:
@@ -329,13 +326,18 @@ def yield_cells(self):
329326
for val in row:
330327
yield self.Cell(self, val)
331328

329+
@property
332330
def cells(self):
333331
return [cell for cell in self.yield_cells()]
334332

335-
def rows(self):
333+
def yield_rows(self):
336334
for row in self._values:
337335
yield [self.Cell(self, val) for val in row]
338336

337+
@property
338+
def rows(self):
339+
return [row for row in self.yield_rows()]
340+
339341
def map(self, func):
340342
"""Returns <Decimal> of block sum"""
341343
for row in self._rows:
@@ -389,5 +391,31 @@ def match(self, regex):
389391
return True
390392
return False
391393

392-
def __str__(self):
393-
return self.value
394+
395+
class SheetsUpdate(object):
396+
397+
"""creates google-api-wrapper ready batchUpdate
398+
request dictionaries
399+
"""
400+
401+
@staticmethod
402+
def format_row(sheet_id, start, end, red=0, green=0, blue=0):
403+
return {
404+
"repeatCell": {
405+
"range": {
406+
"sheetId": sheet_id,
407+
"startRowIndex": start,
408+
"endRowIndex": end
409+
},
410+
"cell": {
411+
"userEnteredFormat": {
412+
"backgroundColor": {
413+
"red": red,
414+
"green": green,
415+
"blue": blue
416+
}
417+
}
418+
},
419+
"fields": "userEnteredFormat(backgroundColor)"
420+
}
421+
}

‎google_objects/slides.py

Copy file name to clipboardExpand all lines: google_objects/slides.py
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import re
1111
import logging
12-
import httplib2
1312

1413
from apiclient.errors import HttpError
1514

@@ -84,10 +83,6 @@ def push_updates(self, presentation_id, updates):
8483
).execute()
8584

8685

87-
88-
# objects
89-
90-
9186
class Presentation(GoogleObject):
9287

9388
"""Google Presentation Object,
@@ -526,9 +521,6 @@ def __str__(self):
526521
print self.text
527522

528523

529-
# update requests
530-
531-
532524
class SlidesUpdate(object):
533525

534526
"""creates google-api-wrapper ready batchUpdate

‎tests/test_drive.py

Copy file name to clipboardExpand all lines: tests/test_drive.py
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ def test_permissions(drive_file):
4242
type='user',
4343
)
4444

45-
# test properties
46-
print 'as dict:'
47-
print permission.__dict__
48-
4945
assert hasattr(permission, 'id')
5046
assert hasattr(permission, 'email')
5147
assert hasattr(permission, 'role')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.