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 d13f279

Browse filesBrowse files
committed
updated README formatting
1 parent 66a5db9 commit d13f279
Copy full SHA for d13f279

File tree

1 file changed

+71
-74
lines changed
Filter options

1 file changed

+71
-74
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+71-74Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Currently supports Python 2.7 :snake::snake::snake:
44

55
## Installation
66
```bash
7-
$ pip install google-objects
7+
$ pip install google-objects
88
```
99

1010
## Usage
@@ -15,143 +15,140 @@ Requires a valid Google API Credentials object from Google's excellent oauth2lib
1515
- [x] Retrieve drive 'About' information:
1616

1717
```python
18-
from google_objects import DriveAPI
18+
from google_objects import DriveAPI
1919

20-
gdrive = DriveAPI(OAUTH2LIB_CREDS)
21-
about = gdrive.get_about()
20+
gdrive = DriveAPI(OAUTH2LIB_CREDS)
21+
about = gdrive.get_about()
2222

23-
print about.email
24-
print about.name
23+
print about.email
24+
print about.name
2525

26-
# prints link to profile photo
27-
print about.photo
26+
# prints link to profile photo
27+
print about.photo
2828

29-
# ...
29+
# ...
3030
```
3131

3232
- [x] List files in drive by type:
3333

3434
```python
35-
files_by_type = {
36-
'slides': gdrive.list_files('presentation'),
37-
'folders': gdrive.list_files('folder'),
38-
'spreadsheets': gdrive.list_files('spreadsheets'),
39-
}
35+
files_by_type = {
36+
'slides': gdrive.list_files('presentation'),
37+
'folders': gdrive.list_files('folder'),
38+
'spreadsheets': gdrive.list_files('spreadsheets'),
39+
}
4040

41-
for file in files_by_type['folders']:
42-
print file.id
43-
print file.name
41+
for file in files_by_type['folders']:
42+
print file.id
43+
print file.name
4444

45-
for file in files_by_type['spreadsheets']:
46-
# prints list of parent folder IDs
47-
print file.parents
45+
for file in files_by_type['spreadsheets']:
46+
# prints list of parent folder IDs
47+
print file.parents
4848

49-
# ...
49+
# ...
5050
```
5151

5252
- [x] Copy and share file:
5353

5454
```python
55-
file = gdrive.get_file('FILE_ID')
56-
new_file = file.copy('NEW_FILE_NAME', ['PARENT_FOLDER_1', 'PARENT_FOLDER_2'])
57-
58-
# allow myfriend@hotmail.com to view
59-
permission = new_file.add_permission('myfriend@hotmail.com')
60-
61-
# print newly created permission information
62-
print permission.role, permission.type, permission.email
55+
file = gdrive.get_file('FILE_ID')
56+
new_file = file.copy('NEW_FILE_NAME', ['PARENT_FOLDER_1', 'PARENT_FOLDER_2'])
57+
58+
# allow myfriend@hotmail.com to view
59+
permission = new_file.add_permission('myfriend@hotmail.com')
60+
61+
# print newly created permission information
62+
print permission.role, permission.type, permission.email
6363
```
6464

6565
### Google Slides v1
6666

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

6969
```python
70-
from google_objects import SlidesAPI
70+
from google_objects import SlidesAPI
7171

72-
gslides = SlidesAPI(OAUTHLIB_CREDS)
73-
presentation = gslides.get_presentation('PRESENTATION_ID')
72+
gslides = SlidesAPI(OAUTHLIB_CREDS)
73+
presentation = gslides.get_presentation('PRESENTATION_ID')
7474

75-
# print slides attributes
76-
for slide in presentation:
77-
print slide.id
75+
# print slides attributes
76+
for slide in presentation:
77+
print slide.id
7878

79-
for element in slide: # equivalent to 'for element in presentation.elements()'
80-
print element.type
81-
# Shape, Table, etc
82-
79+
for element in slide: # equivalent to 'for element in presentation.elements()'
80+
print element.type
81+
# Shape, Table, etc
8382
```
8483

8584
- [x] Check text in shape:
8685

8786
```python
88-
shape = presentation.get_element_by_id('SHAPE_ID')
89-
for segment in shape.text:
90-
print segment.text
91-
87+
shape = presentation.get_element_by_id('SHAPE_ID')
88+
for segment in shape.text:
89+
print segment.text
9290
```
9391

9492
- [x] Batch update every cell in table:
9593

9694
```python
97-
# use with to perform batch updates in block
98-
with presentation as pres:
99-
table = pres.get_element_by_id('TABLE_ID')
100-
for cell in table:
101-
print cell.location # tuple containing cell location
102-
for segment in cell.text:
103-
# update cell
104-
segment.text = 'UPDATED_VALUE'
105-
95+
# use with to perform batch updates in block
96+
with presentation as pres:
97+
table = pres.get_element_by_id('TABLE_ID')
98+
for cell in table:
99+
print cell.location # tuple containing cell location
100+
for segment in cell.text:
101+
# update cell
102+
segment.text = 'UPDATED_VALUE'
106103
```
107104

108105
### Google Sheets v4
109106

110107
- [x] Retrieve spreadsheet and loop through sheets:
111108

112109
```python
113-
from google_objects import SheetsAPI
110+
from google_objects import SheetsAPI
114111

115-
gsheets = SheetsAPI(OAUTHLIB_CREDS)
116-
spreadsheet = gsheets.get_spreadsheet('SPREADSHEET_ID')
112+
gsheets = SheetsAPI(OAUTHLIB_CREDS)
113+
spreadsheet = gsheets.get_spreadsheet('SPREADSHEET_ID')
117114

118-
for sheet in spreadsheet:
119-
print sheet.id, sheet.title
115+
for sheet in spreadsheet:
116+
print sheet.id, sheet.title
120117
```
121118

122119
- [x] Get sheet by name and return its full block of values:
123120

124121
```python
125-
sheet = spreadsheet['Sheet 1']
126-
values = sheet.values()
122+
sheet = spreadsheet['Sheet 1']
123+
values = sheet.values()
127124
```
128125

129126
- [x] Get named range value block:
130127

131128
```python
132-
named_ranges = spreadsheet.named_ranges('SHEET_NAME!A:C')
133-
for rng in named_range:
134-
values = named_range.get_block()
129+
named_ranges = spreadsheet.named_ranges('SHEET_NAME!A:C')
130+
for rng in named_range:
131+
values = named_range.get_block()
135132
```
136133

137134
- [x] Update values block:
138135

139136
```python
140-
values = spreadsheet.get_range('SHEET_NAME!A:C')
141-
# loop through rows
142-
for i, row in enumerate(values):
143-
values[i] = [1, 2, 3]
144-
print row
145-
values.update()
146-
147-
# you can also use the slice syntax for updating..
148-
values[2:5] = [[1,2,4], [4, 5, 6], [6, 7, 8]]
149-
values.update()
137+
values = spreadsheet.get_range('SHEET_NAME!A:C')
138+
# loop through rows
139+
for i, row in enumerate(values):
140+
values[i] = [1, 2, 3]
141+
print row
142+
values.update()
143+
144+
# you can also use the slice syntax for updating..
145+
values[2:5] = [[1,2,4], [4, 5, 6], [6, 7, 8]]
146+
values.update()
150147
```
151148

152149
- [x] Append to values block:
153150

154151
```python
155-
to_append = [[1, 2, 3], [4, 5, 6]]
156-
values.append(to_append)
152+
to_append = [[1, 2, 3], [4, 5, 6]]
153+
values.append(to_append)
157154
```

0 commit comments

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