gdata.spreadsheet.text_db | index /usr/local/svn/gdata-python-client/src/gdata/spreadsheet/text_db.py

`# Copyright Google 2007-2008, all rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.`

Modules
`` |  |
StringIO | gdata |  |

Classes
`` |  | __builtin__.list(__builtin__.object) RecordResultSet __builtin__.object Database DatabaseClient Record Table exceptions.Exception(exceptions.BaseException) Error BadCredentials CaptchaRequired
class BadCredentials(Error)
`` |  | Method resolution order: BadCredentials Error exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors inherited from Error: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see x.__class__.__doc__ for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object at 0x74d100> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class CaptchaRequired(Error)
`` |  | Method resolution order: CaptchaRequired Error exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors inherited from Error: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see x.__class__.__doc__ for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object at 0x74d100> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class Database(__builtin__.object)
`` | `Provides interface to find and create tables. The database represents a Google Spreadsheet.`
| Methods defined here: CreateTable(self, name, fields=None) `Add a new worksheet to this spreadsheet and fill in column names. Args: name: str The title of the new worksheet. fields: list of strings The column names which are placed in the first row of this worksheet. These names are converted into XML tags by the server. To avoid changes during the translation process I recommend using all lowercase alphabetic names. For example ['somelongname', 'theothername'] Returns: Table representing the newly created worksheet.` Delete(self) `Deletes the entire database spreadsheet from Google Spreadsheets.` GetTables(self, worksheet_id=None, name=None) `Searches for a worksheet with the specified ID or name. The list of results should have one table at most, or no results if the id or name were not found. Args: worksheet_id: str The ID of the worksheet, example: 'od6' name: str The title of the worksheet. Returns: A list of length 0 or 1 containing the desired Table. A list is returned to make this method feel like GetDatabases and GetRecords.` __init__(self, spreadsheet_entry=None, database_client=None) `Constructor for a database object. Args: spreadsheet_entry: gdata.docs.DocumentListEntry The Atom entry which represents the Google Spreadsheet. The spreadsheet's key is extracted from the entry and stored as a member. database_client: DatabaseClient A client which can talk to the Google Spreadsheets servers to perform operations on worksheets within this spreadsheet.` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`
class DatabaseClient(__builtin__.object)
`` | `Allows creation and finding of Google Spreadsheets databases. The DatabaseClient simplifies the process of creating and finding Google Spreadsheets and will talk to both the Google Spreadsheets API and the Google Documents List API.`
| Methods defined here: CreateDatabase(self, name) `Creates a new Google Spreadsheet with the desired name. Args: name: str The title for the spreadsheet. Returns: A Database instance representing the new spreadsheet.` GetDatabases(self, spreadsheet_key=None, name=None) `Finds spreadsheets which have the unique key or title. If querying on the spreadsheet_key there will be at most one result, but searching by name could yield multiple results. Args: spreadsheet_key: str The unique key for the spreadsheet, this usually in the the form 'pk23...We' or 'o23...423.12,,,3'. name: str The title of the spreadsheets. Returns: A list of Database objects representing the desired spreadsheets.` SetCredentials(self, username, password) `Attempts to log in to Google APIs using the provided credentials. If the username or password are None, the client will not request auth tokens. Args: username: str (optional) Example: jo@example.com password: str (optional)` __init__(self, username=None, password=None) `Constructor for a Database Client. If the username and password are present, the constructor will contact the Google servers to authenticate. Args: username: str (optional) Example: jo@example.com password: str (optional)` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`
class Error(exceptions.Exception)
`` |  | Method resolution order: Error exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see x.__class__.__doc__ for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object at 0x74d100> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class Record(__builtin__.object)
`` | `Represents one row in a worksheet and provides a dictionary of values. Attributes: custom: dict Represents the contents of the row with cell values mapped to column headers.`
| Methods defined here: Delete(self) ExtractContentFromEntry(self, entry) `Populates the content and row_id based on content of the entry. This method is used in the Record's contructor. Args: entry: gdata.spreadsheet.SpreadsheetsList The Atom entry representing this row in the worksheet.` Pull(self) `Query Google Spreadsheets to get the latest data from the server. Fetches the entry for this row and repopulates the content dictionary with the data found in the row.` Push(self) `Send the content of the record to spreadsheets to edit the row. All items in the content dictionary will be sent. Items which have been removed from the content may remain in the row. The content member of the record will not be modified so additional fields in the row might be absent from this local copy.` __init__(self, content=None, row_entry=None, spreadsheet_key=None, worksheet_id=None, database_client=None) `Constructor for a record. Args: content: dict of strings Mapping of string values to column names. row_entry: gdata.spreadsheet.SpreadsheetsList The Atom entry representing this row in the worksheet. spreadsheet_key: str The ID of the spreadsheet in which this row belongs. worksheet_id: str The ID of the worksheet in which this row belongs. database_client: DatabaseClient The client which can be used to talk the Google Spreadsheets server to edit this row.` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`
class RecordResultSet(__builtin__.list)
`` | `A collection of rows which allows fetching of the next set of results. The server may not send all rows in the requested range because there are too many. Using this result set you can access the first set of results as if it is a list, then get the next batch (if there are more results) by calling GetNext().`
| Method resolution order: RecordResultSet __builtin__.list __builtin__.object Methods defined here: GetNext(self) `Fetches the next batch of rows in the result set. Returns: A new RecordResultSet.` __init__(self, feed, client, spreadsheet_key, worksheet_id) Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` Methods inherited from __builtin__.list: __add__(...) `x.__add__(y) <==> x+y` __contains__(...) `x.__contains__(y) <==> y in x` __delitem__(...) `x.__delitem__(y) <==> del x[y]` __delslice__(...) `x.__delslice__(i, j) <==> del x[i:j] Use of negative indices is not supported.` __eq__(...) `x.__eq__(y) <==> x==y` __ge__(...) `x.__ge__(y) <==> x>=y` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __gt__(...) `x.__gt__(y) <==> x>y` __iadd__(...) `x.__iadd__(y) <==> x+=y` __imul__(...) `x.__imul__(y) <==> x*=y` __iter__(...) `x.__iter__() <==> iter(x)` __le__(...) `x.__le__(y) <==> x<=y` __len__(...) `x.__len__() <==> len(x)` __lt__(...) `x.__lt__(y) <==> x<y` __mul__(...) `x.__mul__(n) <==> x*n` __ne__(...) `x.__ne__(y) <==> x!=y` __repr__(...) `x.__repr__() <==> repr(x)` __reversed__(...) `L.__reversed__() -- return a reverse iterator over the list` __rmul__(...) `x.__rmul__(n) <==> n*x` __setitem__(...) `x.__setitem__(i, y) <==> x[i]=y` __setslice__(...) `x.__setslice__(i, j, y) <==> x[i:j]=y Use of negative indices is not supported.` __sizeof__(...) `L.__sizeof__() -- size of L in memory, in bytes` append(...) `L.append(object) -- append object to end` count(...) `L.count(value) -> integer -- return number of occurrences of value` extend(...) `L.extend(iterable) -- extend list by appending elements from the iterable` index(...) `L.index(value, [start, [stop]]) -> integer -- return first index of value` insert(...) `L.insert(index, object) -- insert object before index` pop(...) `L.pop([index]) -> item -- remove and return item at index (default last)` remove(...) `L.remove(value) -- remove first occurrence of value` reverse(...) `L.reverse() -- reverse *IN PLACE*` sort(...) `L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1` Data and other attributes inherited from __builtin__.list: __hash__ = None __new__ = <built-in method __new__ of type object at 0x755000> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Table(__builtin__.object)
`` |  | Methods defined here: AddRecord(self, data) `Adds a new row to this worksheet. Args: data: dict of strings Mapping of string values to column names. Returns: Record which represents this row of the spreadsheet.` Delete(self) `Deletes this worksheet from the spreadsheet.` FindRecords(self, query_string) `Performs a query against the worksheet to find rows which match. For details on query string syntax see the section on sq under http://code.google.com/apis/spreadsheets/reference.html#list_Parameters Args: query_string: str Examples: 'name == john' to find all rows with john in the name column, '(cost < 19.50 and name != toy) or cost > 500' Returns: RecordResultSet with the first group of matches.` GetRecord(self, row_id=None, row_number=None) `Gets a single record from the worksheet based on row ID or number. Args: row_id: The ID for the individual row. row_number: str or int The position of the desired row. Numbering begins at 1, which refers to the second row in the worksheet since the first row is used for column names. Returns: Record for the desired row.` GetRecords(self, start_row, end_row) `Gets all rows between the start and end row numbers inclusive. Args: start_row: str or int end_row: str or int Returns: RecordResultSet for the desired rows.` LookupFields(self) `Queries to find the column names in the first row of the worksheet. Useful when you have retrieved the table from the server and you don't know the column names.` SetFields(self, fields) `Changes the contents of the cells in the first row of this worksheet. Args: fields: list of strings The names in the list comprise the first row of the worksheet. These names are converted into XML tags by the server. To avoid changes during the translation process I recommend using all lowercase alphabetic names. For example ['somelongname', 'theothername']` __init__(self, name=None, worksheet_entry=None, database_client=None, spreadsheet_key=None, fields=None) Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`

Functions
`` |  | ConvertStringsToColumnHeaders(proposed_headers) `Converts a list of strings to column names which spreadsheets accepts. When setting values in a record, the keys which represent column names must fit certain rules. They are all lower case, contain no spaces or special characters. If two columns have the same name after being sanitized, the columns further to the right have _2, _3 _4, etc. appended to them. If there are column names which consist of all special characters, or if the column header is blank, an obfuscated value will be used for a column name. This method does not handle blank column names or column names with only special characters.`

Data
`` |  | __author__ = 'api.jscudder (Jeffrey Scudder)'

Author
`` |  | api.jscudder (Jeffrey Scudder)