|
41 | 41 | TABLES_URL = 'https://spreadsheets.google.com/feeds/%s/tables' |
42 | 42 | RECORDS_URL = 'https://spreadsheets.google.com/feeds/%s/records/%s' |
43 | 43 | RECORD_URL = 'https://spreadsheets.google.com/feeds/%s/records/%s/%s' |
| 44 | +CELLS_URL = 'https://spreadsheets.google.com/feeds/cells/%s/%s/private/full' |
| 45 | +CELL_URL = ('https://spreadsheets.google.com/feeds/cells/%s/%s/private/full/' |
| 46 | + 'R%sC%s') |
| 47 | +LISTS_URL = 'https://spreadsheets.google.com/feeds/list/%s/%s/private/full' |
44 | 48 |
|
45 | 49 |
|
46 | 50 | class SpreadsheetsClient(gdata.client.GDClient): |
@@ -330,13 +334,149 @@ def get_record(self, spreadsheet_key, table_id, record_id, |
330 | 334 | gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken |
331 | 335 | among others. Represents the current user. Defaults to None |
332 | 336 | and if None, this method will look for a value in the |
333 | | - auth_token member of SpreadsheetsClient.""" |
| 337 | + auth_token member of SpreadsheetsClient. |
| 338 | + """ |
334 | 339 | return self.get_entry(RECORD_URL % (spreadsheet_key, table_id, record_id), |
335 | 340 | desired_class=desired_class, auth_token=auth_token, |
336 | 341 | **kwargs) |
337 | 342 |
|
338 | 343 | GetRecord = get_record |
339 | 344 |
|
| 345 | + def get_cells(self, spreadsheet_key, worksheet_id, |
| 346 | + desired_class=gdata.spreadsheets.data.CellsFeed, |
| 347 | + auth_token=None, **kwargs): |
| 348 | + """Retrieves the cells which have values in this spreadsheet. |
| 349 | +
|
| 350 | + Blank cells are not included. |
| 351 | +
|
| 352 | + Args: |
| 353 | + spreadsheet_key: str, The unique ID of this containing spreadsheet. This |
| 354 | + can be the ID from the URL or as provided in a |
| 355 | + Spreadsheet entry. |
| 356 | + worksheet_id: str, The unique ID of the worksheet in this spreadsheet |
| 357 | + whose cells we want. This can be obtained using |
| 358 | + WorksheetEntry's get_worksheet_id method. |
| 359 | + desired_class: class descended from atom.core.XmlElement to which a |
| 360 | + successful response should be converted. If there is no |
| 361 | + converter function specified (converter=None) then the |
| 362 | + desired_class will be used in calling the |
| 363 | + atom.core.parse function. If neither |
| 364 | + the desired_class nor the converter is specified, an |
| 365 | + HTTP reponse object will be returned. Defaults to |
| 366 | + gdata.spreadsheets.data.CellsFeed. |
| 367 | + auth_token: An object which sets the Authorization HTTP header in its |
| 368 | + modify_request method. Recommended classes include |
| 369 | + gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken |
| 370 | + among others. Represents the current user. Defaults to None |
| 371 | + and if None, this method will look for a value in the |
| 372 | + auth_token member of SpreadsheetsClient. |
| 373 | + """ |
| 374 | + return self.get_feed(CELLS_URL % (spreadsheet_key, worksheet_id), |
| 375 | + auth_token=auth_token, desired_class=desired_class, |
| 376 | + **kwargs) |
| 377 | + |
| 378 | + GetCells = get_cells |
| 379 | + |
| 380 | + def get_cell(self, spreadsheet_key, worksheet_id, row_num, col_num, |
| 381 | + desired_class=gdata.spreadsheets.data.CellEntry, |
| 382 | + auth_token=None, **kwargs): |
| 383 | + """Retrieves a single cell from the worksheet. |
| 384 | + |
| 385 | + Indexes are 1 based so the first cell in the worksheet is 1, 1. |
| 386 | +
|
| 387 | + Args: |
| 388 | + spreadsheet_key: str, The unique ID of this containing spreadsheet. This |
| 389 | + can be the ID from the URL or as provided in a |
| 390 | + Spreadsheet entry. |
| 391 | + worksheet_id: str, The unique ID of the worksheet in this spreadsheet |
| 392 | + whose cells we want. This can be obtained using |
| 393 | + WorksheetEntry's get_worksheet_id method. |
| 394 | + row_num: int, The row of the cell that we want. Numbering starts with 1. |
| 395 | + col_num: int, The column of the cell we want. Numbering starts with 1. |
| 396 | + desired_class: class descended from atom.core.XmlElement to which a |
| 397 | + successful response should be converted. If there is no |
| 398 | + converter function specified (converter=None) then the |
| 399 | + desired_class will be used in calling the |
| 400 | + atom.core.parse function. If neither |
| 401 | + the desired_class nor the converter is specified, an |
| 402 | + HTTP reponse object will be returned. Defaults to |
| 403 | + gdata.spreadsheets.data.CellEntry. |
| 404 | + auth_token: An object which sets the Authorization HTTP header in its |
| 405 | + modify_request method. Recommended classes include |
| 406 | + gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken |
| 407 | + among others. Represents the current user. Defaults to None |
| 408 | + and if None, this method will look for a value in the |
| 409 | + auth_token member of SpreadsheetsClient. |
| 410 | + """ |
| 411 | + return self.get_entry( |
| 412 | + CELL_URL % (spreadsheet_key, worksheet_id, row_num, col_num), |
| 413 | + auth_token=auth_token, desired_class=desired_class, **kwargs) |
| 414 | + |
| 415 | + GetCell = get_cell |
| 416 | + |
| 417 | + def get_list_feed(self, spreadsheet_key, worksheet_id, |
| 418 | + desired_class=gdata.spreadsheets.data.ListsFeed, |
| 419 | + auth_token=None, **kwargs): |
| 420 | + """Retrieves the value rows from the worksheet's list feed. |
| 421 | + |
| 422 | + The list feed is a view of the spreadsheet in which the first row is used |
| 423 | + for column names and subsequent rows up to the first blank line are |
| 424 | + records. |
| 425 | +
|
| 426 | + Args: |
| 427 | + spreadsheet_key: str, The unique ID of this containing spreadsheet. This |
| 428 | + can be the ID from the URL or as provided in a |
| 429 | + Spreadsheet entry. |
| 430 | + worksheet_id: str, The unique ID of the worksheet in this spreadsheet |
| 431 | + whose cells we want. This can be obtained using |
| 432 | + WorksheetEntry's get_worksheet_id method. |
| 433 | + desired_class: class descended from atom.core.XmlElement to which a |
| 434 | + successful response should be converted. If there is no |
| 435 | + converter function specified (converter=None) then the |
| 436 | + desired_class will be used in calling the |
| 437 | + atom.core.parse function. If neither |
| 438 | + the desired_class nor the converter is specified, an |
| 439 | + HTTP reponse object will be returned. Defaults to |
| 440 | + gdata.spreadsheets.data.ListsFeed. |
| 441 | + auth_token: An object which sets the Authorization HTTP header in its |
| 442 | + modify_request method. Recommended classes include |
| 443 | + gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken |
| 444 | + among others. Represents the current user. Defaults to None |
| 445 | + and if None, this method will look for a value in the |
| 446 | + auth_token member of SpreadsheetsClient. |
| 447 | + """ |
| 448 | + return self.get_feed(LISTS_URL % (spreadsheet_key, worksheet_id), |
| 449 | + auth_token=auth_token, desired_class=desired_class, |
| 450 | + **kwargs) |
| 451 | + |
| 452 | + GetListFeed = get_list_feed |
| 453 | + |
| 454 | + def add_list_entry(self, list_entry, spreadsheet_key, worksheet_id, |
| 455 | + auth_token=None, **kwargs): |
| 456 | + """Adds a new row to the worksheet's list feed. |
| 457 | +
|
| 458 | + Args: |
| 459 | + list_entry: gdata.spreadsheets.data.ListsEntry An entry which contains |
| 460 | + the values which should be set for the columns in this |
| 461 | + record. |
| 462 | + spreadsheet_key: str, The unique ID of this containing spreadsheet. This |
| 463 | + can be the ID from the URL or as provided in a |
| 464 | + Spreadsheet entry. |
| 465 | + worksheet_id: str, The unique ID of the worksheet in this spreadsheet |
| 466 | + whose cells we want. This can be obtained using |
| 467 | + WorksheetEntry's get_worksheet_id method. |
| 468 | + auth_token: An object which sets the Authorization HTTP header in its |
| 469 | + modify_request method. Recommended classes include |
| 470 | + gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken |
| 471 | + among others. Represents the current user. Defaults to None |
| 472 | + and if None, this method will look for a value in the |
| 473 | + auth_token member of SpreadsheetsClient. |
| 474 | + """ |
| 475 | + return self.post(list_entry, LISTS_URL % (spreadsheet_key, worksheet_id), |
| 476 | + auth_token=auth_token, **kwargs) |
| 477 | + |
| 478 | + AddListEntry = add_list_entry |
| 479 | + |
340 | 480 |
|
341 | 481 | class SpreadsheetQuery(gdata.client.Query): |
342 | 482 |
|
|
0 commit comments