What's new? | Help | Directory | Sign in
Google
gdatacopier
Bi-directional copy utility & API for Google docs
  
  
  
  
    
Search
for
Updated Oct 09, 2007 by devraj
Labels: Phase-Implementation, Featured
APIDocumentation  
Quick tour of the GoogleDocCopier class

API documentation

GoogleDocCopier is a class that consits of the following methods, here is a brief commentary on each of them.

def login(self, username, password):

Used to perform a login using the GData API and urllib2

This method may raise the following exceptions:
  • NotLoggedInSimulatedBrowser
  • SimluatedBrowserLoginFailed
  • NotEnoughCookiesFromGoogle

def logout(self):

Closes all connections and re-sets instance variables to default values. May be required if your script needs to re-login as multiple users.
def export_document(self, document_id, file_format, output_path):

Exports a document, you will require to provide the Google document id, a file format that Google recognizes and a file name to write to.
The GoogleDocFormat class helps you get the file_formats right, the valid programmatic values are:

This method may raise the following exceptions:
  • DocumentDownloadURLError
  • FailedToWriteDocumentToFile
  • FailedToDownloadFile
  • NotLoggedInSimulatedBrowser
def import_document(self, document_path, document_title = None):
Detects the content type of a document and accordingly imports it as a spreadsheet or a document. If a title is not provided, the first part of the file name will be used as the title.

This method may raise the following exceptions:
  • FileNotFound
  • InvalidContentType
  • FailedToUploadFile

def export_spreadsheet(self, document_id, file_format, output_path = None):

def cache_document_lists(self):

Calls get_document_list and get_spreadsheet_list and stores the output into two instance variables. This minimizes the number of restful calls that we make if we are downloading a whole bunch of documents.

You don't have to use the caching features if you don't want to.

def get_cached_document_list(self):

Returns a set [] of documents entries that have been previously cached. If the cache is empty, the method will download a live list, cache it and return the cached list.

def get_cached_spreadsheet_list(self):

def get_document_list(self):

def get_spreadsheet_list(self):

Returns a set [] of dictionaries {} of spreadsheet information live from the Google servers. Each dictionary entry contains:

def has_item(self, document_id):

Checks to see if the provided Google document id exists. Returns True or False
def is_spreadsheet(self, document_id):
Checks to see if the provided Google document id is a spreadsheet or not. Returns True or False.

def is_document(self, document_id):

Checks to see if the provided Google document id is a document or not. Returns True or False


Sign in to add a comment