My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
APIDocumentation  
Quick tour of the GoogleDocCopier class
Phase-Implementation, Deprecated
Updated Sep 13, 2009 by devraj

Please note that the development of the GDataCopier API will be discontinued as of the 2.0 RoadMap. Google now officially provides a mechanism to export documents as part of the 1.3 GData API.

Thanks for your interest and using the GDataCopier API in the past.

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:
  • GoogleDocFormat.OOWriter
  • GoogleDocFormat.MSWord
  • GoogleDocFormat.PDF
  • GoogleDocFormat.RichText
  • GoogleDocFormat.Text

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:

  • updated, the last update date for the document
  • google_id, the document id extracted from the alternate url
  • title, the descriptive title for the document

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
Powered by Google Project Hosting