GoogleCalendar (version 0.6) | |
(GCPI) Google Calendar Python Interface.
This package provides some simple classes and methods to communicate
with a Google Calendar Account, and, of course, create new
events/comments or modifying / delete the existing ones.
A simple usage :
from GoogleCalendar import *
gCalMNG = GoogleCalendarMng()
gCalMNG.connect ("some_login@gmail.com", "some_password")
calendar = gCalMNG.getCalendar ("myCalendarForTest")
events = calendar.getEvents()
for event in events:
print event.getTitle()
print event.getContent()
print time.strftime("%Y-%m-%dT%H:%M:%S" ,
time.localtime(event.getStartTime()))
print time.strftime("%Y-%m-%dT%H:%M:%S" ,
time.localtime(event.getEndTime()))
Adding new events.
There are two mechanisms:
- Creating a single event, and adding this one into calendar.
ev = newEvent("Lluis", "lluis.gesa@gmail.org",
"Meeting", "With Aleix to talk about work", "La Garriga",
time.mktime((2007,03,27,19,30,00)),
time.mktime((2007,03,27,21,30,00)))
calendar.addEvent (ev)
- Creating directly the event into calendar:
calendar.newEvent ("Meeting", "With Aleix to talk about work", "La Garriga",
time.mktime((2007,03,27,19,30,00)),
time.mktime((2007,03,27,21,30,00)))
with this second mechanisms, the user and email used are the same of owner of calendar
Updating events.
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
event.setContent (event.getContent() + "Changes on location")
event.setLocation ("Barcelona")
event.update()
Deleting events.
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
event.delete()
Adding comments.
Like events, there are two methods:
- Directly over event
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
event.newComment ("comment test")
- Using a global method for create.
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
cmt = newComment ("some_user_mail", "some_email", "Coment test2")
event.addComment (cmt)
Updating comments.
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
comments = event.getComments()
for comment in comments:
if comment.getContent() == "comment test":
comment.setContent("Updated")
comment.update()
Deleting comments.
events = calendar.getEvents()
for event in events:
if event.getTitle() == "Meeting":
comments = event.getComments()
for comment in comments:
if comment.getContent() == "Updated":
comment.delete()
Considerations and notes:
When a event or comment are added, to work with new instance a
GoogleCalendar::gCalendar::getEvents or
GoogleCalendar::gEvent::getComments must be already executed, new
versions will provide self-sincronize, in another words, when a new
event will be created, after call the @ref
GoogleCalendar::gCalendar::addEvent, event object will be modified
with new information, like the edit URL created by Google Account.
Emails fields used when creating events or comments seems to be used
only for validation when Google Account processes the information,
the real user showed as author are the user used to connect with the
account. When a invalid email is given in this methods, Google
Calendar returns an error.
Datetime strings used by Google Api is based on iso8601, this module
use @a xml.utils.iso8601 to realize the conversions, but some
considerations over timezone and daylight has been made in code to
perform correct conversions, but it is possible that implemented code
has a mistake, please report to the author the circumstances when a
error in datetime conversions are found.
Classes |
| | |
- GoogleCalendarMng
- gItem
-
- gCalendar
- gComment
- gEvent
class GoogleCalendarMng |
| |
Class to manage the interaction with a Google Calendar Account.
Provides protected methods to make the http(s) connections to transmit
and receive gdata information |
| |
Methods defined here:
- connect(self, usr, pwd)
- ## Connect manager with a online Google Calendar Account.
- getCalendar(self, calendartitle)
- ## To get the gCalendar with the given name.
- getCalendars(self)
- Manager previously must be synchronized.
- login(self)
- ## Return the login user used to connect.
- setDefaultCalendar(self, calendar)
- ## To set the internal calendar to use in GoogleCalendar.getEvent.
- synchronize(self)
- Initialize internal array of available calendars in the account.
|
class gCalendar(gItem) |
| |
Class representing a Google Calendar. |
| |
Methods defined here:
- __init__(self, googlecalmng)
- addEvent(self, event)
- ## To add a event into Google Calendar Account.
- getEvents(self, searchstring='*')
- If no parameters are given, return All events Searchstring
parameter can be used to perform a custom search of events, the method
used is the same of search field showed in Google Calendar.
- getID(self)
- Only accessible with calendars retrieved from a Google Account.
- getSecureURL(self)
- Only accessible with calendars retrieved from a Google Account.
- getTitle(self)
- ## To get the name of the calendar.
- newEvent(self, title, content, where, start, end)
- ## To add a new event into Google Calendar Account.
- setTitle(self, content)
- ## To set the name of the calendar.
Methods inherited from gItem:
- delete(self)
- ## To delete the item from Google Calendar.
- getAsTabulatedXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toprettyxml.
- getAsXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toxml.
- getEditURL(self)
- Only accessible with items retrieved from a Google Account.
- readFromDom(self, dom)
- Parameter must be a element of type xml.dom.minidom.
- readFromXMLString(self, strxml)
- Internally uses xml.dom.minidom.parseString.
- update(self)
- The items to be updated must implement a getXMLForSend, a method
to build the minimal XML to store de information needed for update
|
class gComment(gItem) |
| |
Class representing a Google Calendar Comment. |
| |
Methods defined here:
- __init__(self, googlecalmng)
- getAuthorEmail(self)
- ## To get the email of the author.
- getAuthorName(self)
- ## To get the name of the author.
- getContent(self)
- ## To get the comment.
- getID(self)
- Only accessible with calendars retrieved from a Google Account.
- getXMLForSend(self)
- When comment are added or updated into a Google Calendar Event,
some elements presents in a comment previously retrieved from
web isn't accepted in a HTTP Put call. Is for this reason that
methods getAsXMLString or getAsTabulatedXMLString can't be
used.
- setAuthorEmail(self, value)
- ## To set the email of the author.
- setAuthorName(self, value)
- ## To get the name of the author.
- setContent(self, content)
- ## To set the comment.
Methods inherited from gItem:
- delete(self)
- ## To delete the item from Google Calendar.
- getAsTabulatedXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toprettyxml.
- getAsXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toxml.
- getEditURL(self)
- Only accessible with items retrieved from a Google Account.
- readFromDom(self, dom)
- Parameter must be a element of type xml.dom.minidom.
- readFromXMLString(self, strxml)
- Internally uses xml.dom.minidom.parseString.
- update(self)
- The items to be updated must implement a getXMLForSend, a method
to build the minimal XML to store de information needed for update
|
class gEvent(gItem) |
| |
Class representing a Google Event. |
| |
Methods defined here:
- __init__(self, googlecalmng)
- addComment(self, comment)
- ## To add a comment
- getAuthorEmail(self)
- ## To get the email of the author.
- getAuthorName(self)
- ## To get the name of the author.
- getCommentURL(self)
- Only usable with a event retrieved from a Google Account.
- getComments(self)
- ## To get a list of the gComment items found in the event
- getContent(self)
- ## To get the description of the event.
- getEndTime(self)
- Value returned is a datetime object
- getID(self)
- Return the Google Event Identification, only accessible with events
retrieved from a Google Account, new events hasn't this ID .
- getLocation(self)
- ## To get the location related with event.
- getStartTime(self)
- Value returned is a datetime object
- getTitle(self)
- ## To get the subject of the event.
- getXMLForSend(self)
- When events are added or updated into a Google Calendar Account,
some elements presents in a event previously retrieved from
web isn't accepted in a HTTP Put call. Is for this reason that
methods getAsXMLString or getAsTabulatedXMLString can't be
used.
- newComment(self, comment)
- ## To create a comment directly into event
- setAuthorEmail(self, value)
- ## To set the email of the author.
- setAuthorName(self, value)
- ## To get the name of the author.
- setContent(self, content)
- ## To set the description of the event.
- setEndTime(self, datetime)
- Parameter must be a datetime object
- setLocation(self, value)
- ## To set the location related with event.
- setStartTime(self, datetime)
- Parameter must be a datetime object
- setTitle(self, content)
- ## To set the subject of the event.
Methods inherited from gItem:
- delete(self)
- ## To delete the item from Google Calendar.
- getAsTabulatedXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toprettyxml.
- getAsXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toxml.
- getEditURL(self)
- Only accessible with items retrieved from a Google Account.
- readFromDom(self, dom)
- Parameter must be a element of type xml.dom.minidom.
- readFromXMLString(self, strxml)
- Internally uses xml.dom.minidom.parseString.
- update(self)
- The items to be updated must implement a getXMLForSend, a method
to build the minimal XML to store de information needed for update
|
class gItem |
| |
Base class common to all Google Calendar elements : Calendar itself, events, comments.. |
| |
Methods defined here:
- __init__(self, googlecalmng)
- delete(self)
- ## To delete the item from Google Calendar.
- getAsTabulatedXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toprettyxml.
- getAsXMLString(self)
- Return the item in XML format, internally call xml.dom.minidom.toxml.
- getEditURL(self)
- Only accessible with items retrieved from a Google Account.
- readFromDom(self, dom)
- Parameter must be a element of type xml.dom.minidom.
- readFromXMLString(self, strxml)
- Internally uses xml.dom.minidom.parseString.
- update(self)
- The items to be updated must implement a getXMLForSend, a method
to build the minimal XML to store de information needed for update
| |
Functions |
| | |
- newComment(user, email, content)
- User and Email are used by Google Account only to be verified. The
comment of event will be the user used to connect to de account
- newEvent(user, email, title, content, where, start, end)
- User and Email are used by Google Account only to be verified. The
author of event will be the user used to connect to de account
|