aboutsummaryrefslogtreecommitdiffstats
path: root/libical/src/python
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>2003-11-19 00:33:30 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-11-19 00:33:30 +0800
commit58f1b46675ef29528f51e5c44fe0e087bda5d82d (patch)
tree725648cf84182762d9dc2ac5846b233203411d59 /libical/src/python
parentb47685534d7e5738d712962334537bb329831b9e (diff)
downloadgsoc2013-evolution-58f1b46675ef29528f51e5c44fe0e087bda5d82d.tar.gz
gsoc2013-evolution-58f1b46675ef29528f51e5c44fe0e087bda5d82d.tar.zst
gsoc2013-evolution-58f1b46675ef29528f51e5c44fe0e087bda5d82d.zip
Remove libical from this tree, it resides in e-d-s now.
svn path=/trunk/; revision=23417
Diffstat (limited to 'libical/src/python')
-rw-r--r--libical/src/python/.cvsignore10
-rw-r--r--libical/src/python/Attendee.py114
-rw-r--r--libical/src/python/ChangeLog129
-rw-r--r--libical/src/python/Collection.py124
-rw-r--r--libical/src/python/Component.py799
-rw-r--r--libical/src/python/DerivedProperties.py159
-rw-r--r--libical/src/python/Duration.py92
-rw-r--r--libical/src/python/Error.py10
-rw-r--r--libical/src/python/Gauge.py88
-rw-r--r--libical/src/python/Libical.py36
-rw-r--r--libical/src/python/LibicalWrap.i453
-rw-r--r--libical/src/python/Makefile.am48
-rw-r--r--libical/src/python/Period.py216
-rw-r--r--libical/src/python/Property.py268
-rw-r--r--libical/src/python/Store.py181
-rw-r--r--libical/src/python/Time.py215
-rw-r--r--libical/src/python/littlefile.txt3
-rw-r--r--libical/src/python/python-binding.txt434
-rw-r--r--libical/src/python/test.py603
19 files changed, 0 insertions, 3982 deletions
diff --git a/libical/src/python/.cvsignore b/libical/src/python/.cvsignore
deleted file mode 100644
index 4f03abd9aa..0000000000
--- a/libical/src/python/.cvsignore
+++ /dev/null
@@ -1,10 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-*.lo
-*.la
-*.pyc
-LibicalWrap.c
-LibicalWrap_wrap.doc
-config.c
diff --git a/libical/src/python/Attendee.py b/libical/src/python/Attendee.py
deleted file mode 100644
index 52001ba3e8..0000000000
--- a/libical/src/python/Attendee.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Property.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-from Property import Property
-from types import DictType, StringType, IntType
-
-class Attendee(Property):
- """Class for Attendee properties.
-
- Usage:
- Attendee([dict])
- Attendee([address])
-
- Where:
- dict is an optional dictionary with keys of
- 'value': CAL-ADDRESS string and any parameter: parameter_value entries.
- 'name' and 'value_type' entries in dict are ignored and automatically set
- with the appropriate values.
- address is the CAL-ADDRESS (string) of the Attendee
- """
-
- def __init__(self, arg={}):
-
- assert(isinstance(arg,DictType))
-
- ref = None
-
- if arg!={}:
- ref = arg['ref']
-
- Property.__init__(self,type='ATTENDEE',ref=ref)
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- # Methods for accessing enumerated parameters
- def cn(self, v=None): self._doParam('CN', v)
- def cutype(self, v=None): self._doParam('CUTYPE', v)
- def dir(self, v=None): self._doParam('DIR', v)
- def delegated_from(self, v=None): self._doParam('DELEGATED-FROM', v)
- def delegated_to(self, v=None): self._doParam('DELEGATED-TO', v)
- def language(self, v=None): self._doParam('LANGUAGE', v)
- def member(self, v=None): self._doParam('MEMBER', v)
- def partstat(self, v=None): self._doParam('PARTSTAT', v)
- def role(self, v=None): self._doParam('ROLE', v)
- def rsvp(self, v=None): self._doParam('RSVP', v)
- def sent_by(self, v=None): self._doParam('SENT-BY', v)
-
-
-class Organizer(Property):
- """Class for Organizer property.
- """
-
- def __init__(self, arg={}):
-
- assert(isinstance(arg, DictType))
-
- ref = None
- if arg != {}:
- ref = arg['ref']
- Property.__init__(self, type='ORGANIZER', ref=ref)
-
-## param_t = ( 'CN', 'DIR', 'SENT-BY', 'LANGUAGE' )
-## for param in param_t:
-## self[param] = None
-## if value != None:
-## self.value(value)
-
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- def name(self):
- "Return the name of the property."
- return Property.name(self)
-
- def value_type(self):
- "Return the value type of the property."
- return self._desc['value_type']
-
- # Methods for accessing enumerated parameters
- def cn(self, v=None): self._doParam('CN', v)
- def dir(self, v=None): self._doParam('DIR', v)
- def language(self, v=None): self._doParam('LANGUAGE', v)
- def sent_by(self, v=None): self._doParam('SENT-BY', v)
diff --git a/libical/src/python/ChangeLog b/libical/src/python/ChangeLog
deleted file mode 100644
index ef096f4e3a..0000000000
--- a/libical/src/python/ChangeLog
+++ /dev/null
@@ -1,129 +0,0 @@
-2001-04-04 Eric Busboom <eric@softwarestudio.org>
-
- * Component.py Added Calendar class.
-
- * Componeny.py Changed all component constructor so they cannot
- take string arguments. Now, only NewComponent() can turn an iCal
- string into a component.
-
-
-2001-04-02 Eric Busboom <eric@softwarestudio.org>
-
- * Component.py removed arguments from the Event constructor, since
- I presume that the Component derived classes will always be
- constructed with no arguments.
-
- * Property.py Split out Attendee, Organizer, Time, Duration and
- Period into their own files. Moved remaining classes to Derived
- Properties.pm
-
-
-2001-03-13 Eric Busboom <eric@softwarestudio.org>
-
- * Component.py Added Component.property()
-
-2001-03-10 Patrick Lewis <plewis@inetarena.com>
-
- * Added __str__ method to Collection.Collection
-
- * Component.Component can now be initialized without arguments
-
- * Made _singular_property and _multiple_properties (in Component)
- useful for nearly all the specific component interfaces
-
- * Changed Property.Attendee and Property.Organizer to allow creation
- with no arguments
-
- * Filled in Todo skeleton
-
- * Added test function for an Event
-
-
-2001-03-05 Eric Busboom <eric@softwarestudio.org>
-
- * Property.py Added a lot of exception code to signal failure to
- create a Property.
-
- * DerivedProperties.py Added derived property classes for RDATE
- and TRIGGER, two properties that can have one of two value types.
-
-
-2001-03-04 Eric Busboom <eric@softwarestudio.org>
-
- * Property.pm Added Property.ConstructorFailedError exception
-
- * Component.pm fixed bug in Collection.__setslice__. "," used
- instead of ":"
-
-2001-03-04 Patrick Lewis <plewis@inetarena.com>
-
- * Split Libical.py file into Component.py, Property.py, Collection.py,
- and Store.py
-
- * Added test_* functions to test.py
-
- * Changed component bindings to return a Collection when objects can
- have multiple values
-
- * Changed Component object to allow for creation of an object without
- an initial string
-
- * Added Todo and Journal events
-
-2001-02-28 Eric Busboom <eric@softwarestudio.org>
-
- * Property Remove most internal data. The property now work
- alsmost entirely off of the icalproperty that it holds a reference
- to. Made changes in all derived Properties to accomodate the
- change.
-
- * Property Added __del__
-
- * Component Component.properties() now caches properties that it
- constructs, so two calls to properties() to that get the same
- icalproperty will also get the same Property.
-
- * Property Added Property.__cmp__ to test equality of properties
- based on ical string values
-
-2001-02-27 Eric Busboom <eric@softwarestudio.org>
-
- * Property Added Property.ref() to set/get the reference to the
- Property's internal icalproperty
-
- * Property Property._update_value now changes the icalproperty
- value if a reference has been set.
-
- * Component re-instituted Component.properties(). The routine now
- adds a 'ref' key to the dict that holds the python pointer
- string. The C hex value of the pointer is in the 'pid' key
-
-
-2001-02-27 Patrick Lewis <plewis@inetarena.com>
-
- * Backed out changes to Component removing comp_p;
- Component.comp_p should be restored
-
-2001-02-26 Eric Busboom <eric@softwarestudio.org>
-
- * Period Added test routine,test_period()
-
- * Period implemented methods in period
-
- * Time Addedd addition and subtraction operators
-
-2001-02-25 Eric Busboom <eric@softwarestudio.org>
-
- * Libical.py Added test routine for time, time_test()
-
- * Libical.py Remove end of line chars ('\r\n" ) from
- Property._str__. Caller should add these lines itself
-
- * Liical.py CHanges Time._update_values to set time VALUE type
- based on use of is_date, rather than length of string.
-
- * Libical.py Removed call to _update_value in TIme::timezone
-
-
- * Libical.py changed update_value to _update_value
-
diff --git a/libical/src/python/Collection.py b/libical/src/python/Collection.py
deleted file mode 100644
index 48092aadaa..0000000000
--- a/libical/src/python/Collection.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Collection.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from types import *
-
-class Collection:
- """A group of components that can be modified somewhat like a list.
-
- Usage:
- Collection(componet, propSequence)
-
- component is a Component object
- propSequence is a list or tuple of Property (or subclass of Property)
- of objects already in component
- """
-
- def __init__(self, component, propSequence):
- self._properties = list(propSequence[:])
- self._component = component
-
- def __getslice__(self, beg, end):
- return Collection(self._component, self._properties[beg:end])
-
- def __setslice__(self, beg, end, sequence):
-
- if not isinstance(sequence,ListType):
- raise TypeError, "must assign list (not instance) to slice"
-
- oldProps = self._properties[beg:end]
-
- for p in oldProps:
- self._component.remove_property(p)
-
- self._properties[beg:end] = sequence
- for p in sequence:
- self._component.add_property(p)
-
- def __getitem__(self, i):
- return self._properties[i]
-
- def __setitem__(self, i, prop):
- self._component.remove_property(self._properties[i])
- self._component.add_property(prop)
- self._properties[i]=prop
-
- def __delitem__(self, i):
- self._component.remove_property(self._properties[i])
- del self._properties[i]
-
- def __len__(self):
- return len(self._properties)
-
- def __str__(self):
- s = "[ "
- if len(self._properties) > 0:
- s = s + str(self._properties[0])
- for p in self._properties[1:]:
- s = "%s, %s" % (s, p)
- s = s + " ]"
- return s
-
- def append(self, property):
- self._properties.append(property)
- self._component.add_property(property)
-
-class ComponentCollection:
-
- def __init__(self, parent, componentSequence):
- self._parent = parent
- self._components = list(componentSequence[:])
-
- def __getslice__(self, beg, end):
- return ComponentCollection(self._parent, self._components[beg:end])
-
- def __setslice__(self, beg, end, sequence):
- oldComps = self._components[beg:end]
- self._components.__setslice__(beg, end, sequence)
- for c in sequence:
- self._components.addComponent(c)
- for c in oldComps:
- self._parent.remove_component(c)
-
- def __getitem__(self, i):
- return self._components[i]
-
- def __setitem__(self, i, prop):
- self._parent.remove_component(self._components[i])
- self._parent.add_property(prop)
- self._components[i]=prop
-
- def __delitem__(self, i):
- self._parent.remove_componet(self._components[i])
- del self._components[i]
-
- def __len__(self):
- return len(self._components)
-
- def append(self, property):
- self._components.append(property)
- self._parent.addComponent(property)
diff --git a/libical/src/python/Component.py b/libical/src/python/Component.py
deleted file mode 100644
index 41ef7419db..0000000000
--- a/libical/src/python/Component.py
+++ /dev/null
@@ -1,799 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Component.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-from types import DictType, StringType, IntType
-from Property import Property
-from Collection import *
-from Attendee import Attendee, Organizer
-from Time import Time
-from Duration import Duration
-from Period import Period
-import string
-
-WrapperNULL = None
-
-class Component:
-
- def __init__(self,ref=None,kind=None):
-
- if ref != None:
- self._ref = ref
- elif kind != None:
- self._ref = icalcomponent_new(
- icalcomponent_string_to_kind("VCALENDAR"))
- _kind = icalcomponent_string_to_kind(kind)
- inner = icalcomponent_new(_kind)
-
- icalcomponent_add_component(self._ref,inner);
-
- else:
- raise "Could not construct component of kind" + kind
-
- self.cached_props = {}
- self.cached_comps = {}
-
- def __del__(self):
- if self._ref != None and icalcomponent_get_parent(self._ref) != WrapperNULL:
-
- for k in self.cached_props.keys():
- del self.cached_props[k]
-
- icalcomponent_free(self._ref)
- self._ref = None
-
- def _prop_from_ref(self,p):
-
- if(p == None or p== WrapperNULL):
- return None;
-
- d = {}
- d['value'] = icalproperty_get_value_as_string(p)
- d['name'] = icalproperty_get_name(p)
-
- propkind = icalproperty_string_to_kind(d['name'])
- kind = icalproperty_kind_to_value_kind(propkind)
- d['value_type'] = icalvalue_kind_to_string(kind)
- d['ref'] = p
-
-
- if not self.cached_props.has_key(p):
-
- if d['value_type'] == 'DATE-TIME' or d['value_type'] == 'DATE':
- prop = Time(d,)
- elif d['value_type'] == 'PERIOD':
- prop = Period(d)
- elif d['value_type'] == 'DURATION':
- prop = Duration(d)
- elif d['name'] == 'ATTACH':
- prop = Attach(d)
- elif d['name'] == 'ATTENDEE':
- prop = Attendee(d)
- elif d['name'] == 'ORGANIZER':
- prop = Organizer(d)
- else:
- prop=Property(ref=p)
-
- self.cached_props[p] = prop
-
- def property(self, type):
-
- p = icallangbind_get_first_property(self._ref,type)
-
- if p !=WrapperNULL:
- self._prop_from_ref(p)
- prop = self.cached_props[p]
- return prop
- else :
- return None
-
- def properties(self,type='ANY'):
- """
- Return a list of Property instances, each representing a
- property of the type 'type.'
- """
-
- props = []
-
- p = icallangbind_get_first_property(self._ref,type)
-
- while p !=WrapperNULL and p != None:
-
- self._prop_from_ref(p) # Puts property in self.cached_props
- prop = self.cached_props[p]
- props.append(prop)
- p = icallangbind_get_next_property(self._ref,type)
-
- return Collection(self,props)
-
- def add_property(self, prop):
- "Adds the property object to the component."
-
- if not isinstance(prop,Property):
- raise TypeError
-
- prop_p = prop.ref()
-
- if not prop_p:
- s = str(prop)
- prop_p = icalproperty_new_from_string(s)
-
- if prop_p == WrapperNULL:
- raise "Bad property string: " + s
-
- prop.ref(prop_p)
-
- if icalproperty_get_parent(prop_p)==WrapperNULL:
- icalcomponent_add_property(self._ref, prop_p)
- elif icalproperty_get_parent(prop_p) != self._ref:
- raise "Property is already a child of another component"
-
-
- def remove_property(self,prop):
-
- if prop.ref() and self.cached_props.has_key(prop.ref()):
-
- del self.cached_props[prop.ref()]
- icalcomponent_remove_property(self._ref,prop.ref())
-
- def components(self,type='ANY'):
- comps = []
-
- kind = icalcomponent_string_to_kind(type)
- c = icalcomponent_get_first_component(self._ref,kind);
-
- while c != WrapperNULL and c != None:
-
- if not self.cached_comps.has_key(c):
-
- self.cached_comps[c] = Component(c)
-
- comp = self.cached_comps[c]
- comps.append(comp)
- c = icalcomponent_get_next_component(self._ref,kind);
-
- return comps
-
- def inner_component(self):
-
- inner = icalcomponent_get_inner(self._ref)
-
- if inner == WrapperNULL and inner != None:
- return None
-
- return NewComponent(inner)
-
- def add_component(self, comp):
- "Adds a child component."
-
- if not isinstance(comp,Component):
- raise ValueError("Expected a Component")
-
- if icalcomponent_get_parent(comp._ref) != WrapperNULL:
- raise "Failed to add child component. Child already has a parent";
-
- icalcomponent_add_component(self._ref,comp._ref)
-
- def remove_component(self, comp):
- "Removes a child component"
-
- if not isinstance(comp,Component):
- raise ValueError("Expected a Component")
-
- icalcomponent_remove_component(self._ref,comp._ref)
-
- def as_ical_string(self):
- return self.__str__()
-
- def __str__(self):
-
- return icalcomponent_as_ical_string(self._ref)
-
- def ref(self):
- """ Return the internal reference to the libical icalproperty """
- return self._ref
-
-def CloneComponent(c):
- "Clones a string or C icalcomponent into the right component object."
-
- wasStr=0 # Were we passed a string or an icalcomponent?
-
- if isinstance(c, Component):
- comp = icalparser_parse_string(c.as_ical_string())
- elif isinstance (c, StringType) and string.find(c,"icalcomponent") == -1:
- comp = icalparser_parse_string(c)
- else:
- comp = c
-
- if comp == None or comp == WrapperNULL:
- raise ValueError("Expected a libical reference or an iCal string")
-
- kind = icalcomponent_isa(comp)
- kindStr = icalcomponent_kind_to_string(kind)
-
- if kindStr == 'VCALENDAR':
- inner = icalcomponent_get_inner(comp)
- kind = icalcomponent_isa(inner)
- kindStr = icalcomponent_kind_to_string(kind)
-
- if kindStr == 'VEVENT':
- newComp = Event(comp)
- elif kindStr == 'VTODO':
- newComp = Todo(comp)
- elif kindStr == 'VJOURNAL':
- newComp = Journal(comp)
- else:
- newComp = Component(comp)
-
- # I don't think I need to free the component created when passed a string,
- # as it wasn't created with a _new function.
-
- return newComp
-
-
-def NewComponent(c):
- "Converts a string or C icalcomponent into the right component object."
-
- wasStr=0 # Were we passed a string or an icalcomponent?
-
- if isinstance (c, StringType) and string.find(c,"icalcomponent") == -1:
- comp = icalparser_parse_string(c)
- else:
- comp = c
-
- if comp == None or comp == WrapperNULL:
- raise ValueError("Expected a libical reference or an iCal string")
-
- kind = icalcomponent_isa(comp)
- kindStr = icalcomponent_kind_to_string(kind)
-
- if kindStr == 'VEVENT':
- newComp = Event(comp)
- elif kindStr == 'VTODO':
- newComp = Todo(comp)
- elif kindStr == 'VJOURNAL':
- newComp = Journal(comp)
- else:
- newComp = Component(comp)
-
- # I don't think I need to free the component created when passed a string,
- # as it wasn't created with a _new function.
-
- return newComp
-
-
-class GenericComponent(Component):
-
- def __init__(self,ref=None,kind=None):
-
- if ref != None:
- Component.__init__(self, ref=ref) # Call from subclasses
- elif type != None:
- Component.__init__(self, kind=kind) # Call from subclasses
- else:
- raise ValueError("Expected either a icalcomponent reference or a kind string")
-
-
- self._recurrence_set=None
-
- def _singular_property(self, name, value_type, value=None,
- property_obj=None, enumerated_values=None):
- """Sets or gets the value of a method which exists once per Component.
-
- This is a constructor method for properties without a strictly defined
- object."""
-
- # Depending on the property name, this routine will either
- # operate on the VCALENDAR container or on the inner VEVENT,
- # VTODO, or VJOURNAL
-
- if name in ['METHOD','PRODID','CALSCALE','VERSION']:
- comp = self
- else:
- comp = self.inner_component()
-
- curr_properties = comp.properties(name)
-
- # Get the value
- if value==None:
- if len(curr_properties) == 0:
- return None
- elif len(curr_properties) == 1:
- return curr_properties[0]
- else:
- raise ValueError, "too many properties of type %s" % propType
-
- # Set the value
- else:
- # Check if value is in enumerated_values
- if enumerated_values:
- value = string.upper(value)
- if value not in enumerated_values:
- raise ValueError, "%s is not one of %s" \
- % (value, enumerated_values)
-
- # Create the new property
- if property_obj:
- if not isinstance(value, property_obj):
- # Create a special property_obj property
- if property_obj == Time:
- p = Time(value, name)
- ## p.value_type(value_type)
- elif property_obj == Duration:
- p = Duration(value)
- else:
- p = property_obj()
- ## p.value_type(value_type)
- p.value(value)
- else:
- p = value # value is already a property_obj
- else:
- # Create a generic property
- p = Property(name)
- ## p.value_type(value_type)
- p.value(value)
-
- if len(curr_properties) == 1:
- comp.remove_property(curr_properties[0])
- elif len(curr_properties) > 1:
- raise ValueError, "too many properties of type %s" % propType
-
- comp.add_property(p)
-
- # METHOD, PRODID, CALSCALE and VERSION are properties of the
- # VCALENDAR, not the inner component
-
- def method(self, v=None):
- "Sets or returns the value of the METHOD property."
- return self._singular_property("METHOD", "TEXT", v)
-
- def prodid(self, v=None):
- "Sets or returns the value of the PRODID property."
- return self._singular_property("PRODID", "TEXT", v)
-
- def calscale(self, v=None):
- "Sets or returns the value of the CALSCALE property."
- return self._singular_property("CALSCALE", "TEXT", v)
-
- def version(self, v=None):
- "Sets or returns the value of the Version property."
- return self._singular_property("VERSION", "TEXT", v)
-
- # The remaining properties are all in the inner component
-
- def clone(self):
- "Returns a copy of the object."
- return CloneComponent(self)
-
- def class_prop(self, v=None): # Class is a reserved word
- "Sets or returns the value of the CLASS property."
- if v!=None:
- v = string.upper(v)
- return self._singular_property('CLASS', 'TEXT', v)
-
- def created(self, v=None):
- """Sets or returns the value of the CREATED property.
-
- Usage:
- created(time_obj) # Set the value using a Time object
- created('19970101T123000Z') # Set using an iCalendar string
- created(982362522) # Set using seconds
- created() # Return an iCalendar string
- """
- return self._singular_property("CREATED", "DATE-TIME", v, Time)
-
- def description(self, v=None):
- "Sets or returns the value of the DESCRIPTION property."
- return self._singular_property("DESCRIPTION", "TEXT", v)
-
- def dtstamp(self, v=None):
- """Sets or returns the value of the DTSTAMP property.
-
- Usage:
- dtstamp(time_obj) # Set the value using a Time object
- dtstamp('19970101T123000Z')# Set using an iCalendar string
- dtstamp(982362522) # Set using seconds
- dtstamp() # Return an iCalendar string
- """
- return self._singular_property("DTSTAMP", "DATE-TIME", v, Time)
-
- def dtstart(self, v=None):
- """Sets or returns the value of the DTSTART property.
-
- Usage:
- dtstart(time_obj) # Set the value using a Time object
- dtstart('19970101T123000Z') # Set the value as an iCalendar string
- dtstart(982362522) # Set the value using seconds (time_t)
- dtstart() # Return the time as an iCalendar string
- """
- return self._singular_property("DTSTART", "DATE-TIME", v, Time)
-
- def last_modified(self, v=None):
- """Sets or returns the value of the LAST-MODIFIED property.
-
- Usage:
- last_modified(time_obj) # Set the value using a Time object
- last_modified('19970101T123000Z')# Set using an iCalendar string
- last_modified(982362522) # Set using seconds
- last_modified() # Return an iCalendar string
- """
- return self._singular_property("LAST-MODIFIED", "DATE-TIME", v, Time)
-
- def organizer(self, v=None):
- """Sets or gets the value of the ORGANIZER property.
-
- Usage:
- organizer(orgObj) # Set value using an organizer object
- organizer('MAILTO:jd@not.com') # Set value using a CAL-ADDRESS string
- organizer() # Return a CAL-ADDRESS string
- """
- return self._singular_property('ORGANIZER', 'CAL-ADDRESS', v,
- Organizer)
-
- def recurrence_id(self, v=None):
- """Sets or gets the value for the RECURRENCE-ID property.
-
- Usage:
- recurrence_id(recIdObj) # Set using a Recurrence_Id object
- recurrence_id("19700801T133000") # Set using an iCalendar string
- recurrence_id(8349873494) # Set using seconds from epoch
- recurrence_id() # Return an iCalendar string
- """
- return self._singular_property('RECURRENCE-ID', 'DATE-TIME', v,
- Recurrence_Id)
-
- def sequence(self, v=None):
- """Sets or gets the SEQUENCE value of the Event.
-
- Usage:
- sequence(1) # Set the value using an integer
- sequence('2') # Set the value using a string containing an integer
- sequence() # Return an integer
- """
- if isinstance(v, StringType):
- v = int(str)
- return self._singular_property('SEQUENCE', 'INTEGER', v)
-
- def summary(self, v=None):
- "Sets or gets the SUMMARY value of the Event."
- return self._singular_property('SUMMARY', 'TEXT', v)
-
- def uid(self, v=None):
- "Sets or gets the UID of the Event."
- return self._singular_property('UID', 'TEXT', v)
-
- def url(self, v=None):
- """Sets or returns the URL property."""
- return self._singular_property('URL', 'URI', v)
-
- ####
- # Not quite sure if this is how we want to handle recurrence rules, but
- # this is a start.
-
- def recurrence_set(self):
- "Returns the Events RecurrenceSet object."
- if self._recurrence_set == None: # i.e haven't initialized one
- self._recurrence_set = RecurrenceSet()
- return self._recurrence_set
-
- ###
- # Alarm interface. Returns an ComponentCollection.
-
- def alarms(self, values=None):
- """Sets or returns ALARM components.
-
- Examples:
- alarms((alarm1,)) # Set using Alarm component
- alarms() # Returns an ComponentCollection of all Alarms
- """
- if values!=None:
- for alarm in values:
- self.add_component(alarm)
- else:
- return ComponentCollection(self, self.components('VALARM'))
-
- ####
- # Methods that deal with Properties that can occur multiple times are
- # below. They use the Collection class to return their Properties.
-
- def _multiple_properties(self, name, value_type, values,
- property_obj=None):
- "Processes set/get for Properties that can have multiple instances."
-
- comp = self.inner_component()
-
- # Set value
- if values!=None:
- if not isinstance(values, TupleType) \
- and not isinstance(values, ListType):
- raise TypeError, "%s is not a tuple or list."
-
- # Delete old properties
- for p in comp.properties(name):
- comp.remove_property(p)
-
- for v in values:
- if property_obj: # Specialized properties
- if not isinstance(v, property_obj): # Make new object
- new_prop = property_obj()
- new_prop.value(v)
- else: # Use existing object
- new_prop = v
- else: # Generic properties
- new_prop=Property(name)
- # new_prop.value_type(value_type)
- new_prop.value(v)
-
- comp.add_property(new_prop)
-
- # Get value
- else:
- return Collection(self, comp.properties(name))
-
- def attachments(self, values=None):
- """Sets or returns a Collection of Attach properties.
-
- 'values' can be a sequence containing URLs (strings) and/or file-ish
- objects.
- """
- return self._multiple_properties("ATTACH", "", value, Attach)
-
- def attendees(self, value=None):
- """Sets attendees or returns a Collection of Attendee objects.
-
- If setting the attendees, pass a sequence as the argument.
- Examples:
- # Set using Attendee objects
- attendees((attObj1, attObj2))
- # Set using a CAL-ADDRESS string
- attendees(['MAILTO:jdoe@somewhere.com'])
- # Set using a combination of Attendee objects and strings
- attendees(['MAILTO:jdoe@somewhere.com', attObj1])
- # Returns a list of Attendee objects
- attendees()
-
- When setting the attendees, any previous Attendee objects in the Event
- are overwritten. If you want to add to the Attendees, one way to do it
- is:
-
- attendees().append(Attendee('MAILTO:jdoe@nothere.com'))
- """
- return self._multiple_properties("ATTENDEE", "", value, Attendee)
-
- def categories(self, value=None):
- """Sets categories or returns a Collection of CATEGORIES properties.
-
- If setting the categories, pass a sequence as the argument.
- Examples:
- # Set using string[s]
- categories(('APPOINTMENT', 'EDUCATION'))
- # Returns a list of Category properites
- categories()
-
- When setting the attendees, any previous category Properties in the
- Event are overwritten. If you want to add to the categories, one way
- to do it is:
-
- new_cat=Property('CATEGORIES')
- new_cat.value_type('TEXT')
- new_cat.value('PERSONAL')
- categories().append(new_cat)
- """
- return self._multiple_properties("CATEGORIES", "TEXT", value)
-
- def comments(self, value=None):
- "Sets or returns a Collection of COMMENT properties."
- return self._multiple_properties('COMMENT', 'TEXT', value)
-
- def contacts(self, value=None):
- "Sets or returns a Collection of CONTACT properties."
- return self._multiple_properties('CONTACT', 'TEXT', value)
-
- def related_tos(self, value=None):
- "Sets or returns a Collection of RELATED-TO properties."
- return self._multiple_properties('RELATED-TO', 'TEXT', value)
-
- def x_properties(self, name, value=None):
- "Sets or returns a Collection of X- properties."
- return self._multiple_properties(name, 'TEXT', value)
-
-class Event(GenericComponent):
- "The iCalendar Event object."
-
- def __init__(self,ref=None):
- if ref != None:
- GenericComponent.__init__(self, ref=ref)
- else:
- GenericComponent.__init__(self, kind='VEVENT')
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VEVENT"
-
- def dtend(self, v=None):
- """Sets or returns the value of the DTEND property.
-
- Usage:
- dtend(time_obj) # Set the value using a Time object
- dtend('19970101T123000Z') # Set the value as an iCalendar string
- dtend(982362522) # Set the value using seconds (time_t)
- dtend() # Return the time as an iCalendar string
-
- If the dtend value is being set and duration() has a value, the
- duration property will be removed.
- """
- if v != None:
- duration = self.properties('DURATION')
- for d in duration: # Clear DURATION properties
- self.remove_property(d)
- return self._singular_property("DTEND", "DATE-TIME", v, Time)
-
- def duration(self, v=None):
- """Sets or returns the value of the duration property.
-
- Usage:
- duration(dur_obj) # Set the value using a Duration object
- duration("P3DT12H") # Set value as an iCalendar string
- duration(3600) # Set duration using seconds
- duration() # Return duration as an iCalendar string
-
- If the duration value is being set and dtend() has a value, the dtend
- property will be removed.
- """
-
- if v != None:
- dtend = self.properties('DTEND')
- for d in dtend:
- self.remove_property(d) # Clear DTEND properties
- return self._singular_property("DURATION", "DURATION", v, Duration)
-
- def status(self, v=None):
- "Sets or returns the value of the STATUS property."
-
- # These values are only good for VEVENT components (i.e. don't copy
- # & paste into VTODO or VJOURNAL
- valid_values=('TENTATIVE', 'CONFIRMED', 'CANCELLED')
- return self._singular_property("STATUS", "TEXT", v,
- enumerated_values=valid_values)
-
- def geo(self, v=None):
- """Sets or returns the value of the GEO property.
-
- Usage:
- geo(value) or
- geo() # Returns the icalendar string
-
- 'value' is either a icalendar GEO string or a sequence with two 'float'
- numbers.
-
- Examples:
- geo('40.232;-115.9531') # Set value using string
- geo((40.232, -115.9531)) # Set value using a sequence
- geo() # Returns "40.232;-115.9531"
-
- To get the GEO property represented as a tuple and numbers instead of
- the iCalendar string, use geo_get_tuple().
- """
-
- if isinstance(v, ListType) or isinstance(v, TupleType):
- v = "%s;%s" % (float(v[0]), float(v[1]))
- return self._singular_property("GEO", "FLOAT", v)
-
- def geo_get_tuple(self):
- """Returns the GEO property as a tuple."""
-
- geo = self.geo()
- geo = split(geo, ';')
- return float(geo[0]), float(geo[1])
-
- def location(self, v=None):
- """Sets or returns the LOCATION property."""
- return self._singular_property("LOCATION", "TEXT", v)
-
- def transp(self, v=None):
- """Sets or returns the TRANSP property."""
- ok_values = ('OPAQUE', 'TRANSPARENT')
- return self._singular_property('TRANSP', 'TEXT', v,
- enumerated_values=ok_values)
-
- def resources(self, v=None):
- pass
-
-class Todo(GenericComponent):
- "The iCalendar TODO component."
-
- def __init__(self,ref=None):
- if ref != None:
- GenericComponent.__init__(self, ref=ref)
- else:
- GenericComponent.__init__(self, kind='VTODO')
-
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VTODO"
-
- def completed(self, value=None):
- return self._singular_property('COMPLETED', 'DATE-TIME', value, Time)
-
- def geo(self, value=None):
- if isinstance(v, ListType) or isinstance(v, TupleType):
- v = "%s;%s" % (float(v[0]), float(v[1]))
- return self._singular_property("GEO", "FLOAT", value)
-
- def location(self, value=None):
- return self._singular_property('LOCATION', 'TEXT', value)
-
- def percent(self, value=None):
- if value!=None:
- value = str(int(value))
- return self._singular_property('PERCENT', 'INTEGER', value)
-
- def status(self, value=None):
- if value!=None:
- value=string.upper(value)
- ok_values = ('NEEDS-ACTION', 'COMPLETED', 'IN-PROCESS', 'CANCELLED')
- return self._singular_property('STATUS', 'TEXT', value,
- enumerated_values=ok_values)
-
- def due(self, value=None):
- if value != None:
- duration = self.properties('DURATION')
- for d in duration:
- self.remove_property(d) # Clear DURATION properties
- return self._singular_property('DUE', 'DATE-TIME', value, Time)
-
- def duration(self, value=None):
- if value != None:
- due = self.properites('DUE')
- for d in due:
- self.remove_property(d) # Clear DUE properties
- return self._singular_property("DURATION", "DURATION", value, Duration)
-
- def resources():
- pass
-
-class Journal(GenericComponent):
- "The iCalendar JOURNAL component."
-
- def __init__(self):
- if ref != None:
- GenericComponent.__init__(self, ref=ref)
- else:
- GenericComponent.__init__(self, kind='VJOURNAL')
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VJOURNAL"
-
- def status(self, v=None):
- if v!=None:
- v = string.upper(v)
- ok_values=('DRAFT', 'FINAL', 'CANCELLED')
- return self._singular_property('STATUS', 'TEXT', v,
- enumerated_values=ok_values)
-
diff --git a/libical/src/python/DerivedProperties.py b/libical/src/python/DerivedProperties.py
deleted file mode 100644
index 81248fe7b7..0000000000
--- a/libical/src/python/DerivedProperties.py
+++ /dev/null
@@ -1,159 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: DerivedProperties.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from Property import Property
-from Time import Time
-from Period import Period
-from Duration import Duration
-
-def RDate(arg):
-
- class RDate_Time(Time):
- def __init__(self,arg): Time.__init__(self,arg,"RDATE")
-
- class RDate_Period(Period):
- def __init__(self,arg): Period.__init__(self,arg,"RDATE")
-
- p = None
- for c in [RDate_Time, RDate_Period]:
- try: return c(arg)
- except Property.ConstructorFailedError, d: pass
- raise Property.ConstructorFailedError("Failed to construct RDATE from "+str(arg))
-
-
-def Trigger(arg):
- class Trigger_Time(Time):
- def __init__(self,arg): Time.__init__(self,arg,"TRIGGER")
-
- class Trigger_Duration(Duration):
- def __init__(self,arg): Duration.__init__(self,arg,"TRIGGER")
-
- p = None
- for c in [Trigger_Duration, Trigger_Time]:
- try: return c(arg)
- except Property.ConstructorFailedError, d: pass
- raise Property.ConstructorFailedError("Failed to construct TRIGGER from "+str(arg))
-
-
-
-class Recurrence_Id(Time):
- """Class for RECURRENCE-ID property.
-
- Usage:
- Reccurence_Id(dict) # A normal property dictionary
- Reccurence_Id("19960401") # An iCalendar string
- Reccurence_Id(8349873494) # Seconds from epoch
-
- If the 'dict' constructor is used, 'name' and 'value_type'
- entries in dict are ignored and automatically set with the appropriate
- values.
- """
-
- def __init__(self, dict={}):
- Time.__init__(self, dict)
- Property.name(self, 'RECURRENCE-ID')
-
- def name(self):
- return Property.name(self)
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- # Enumerated parameters
- def value_parameter(self, v=None):
- """Sets or gets the VALUE parameter value.
-
- The value passed should be either "DATE-TIME" or "DATE". Setting this
- parameter has no impact on the property's value_type. Doing something
- like:
-
- rid=Recurrence_Id("19960401") # Sets value & makes value_type="DATE"
- rid.value_parameter("DATE-TIME") # Sets the parameter VALUE=DATE-TIME
-
- Would be allowed (even though it is wrong), so pay attention.
- Verifying the component will reveal the error.
- """
- if v!=None and v!="DATE" and v!="DATE-TIME":
- raise ValueError, "%s is an invalid VALUE parameter value" % str(v)
- self._doParam("VALUE", v)
-
- def tzid(self, v=None):
- "Sets or gets the TZID parameter value."
- self._doParam("TZID", v)
-
- def range_parameter(self, v=None): # 'range' is a builtin function
- "Sets or gets the RANGE parameter value."
- if v!=None and v!="THISANDPRIOR" and v!= "THISANDFUTURE":
- raise ValueError, "%s is an invalid RANGE parameter value" % str(v)
- self._doParam("RANGE", v)
-
-class Attach(Property):
- """A class representing an ATTACH property.
-
- Usage:
- Attach(uriString [, parameter_dict])
- Attach(fileObj [, parameter_dict])
- """
-
- def __init__(self, value=None, parameter_dict={}):
- Property.__init__(self, parameter_dict)
- Property.name(self, 'ATTACH')
- self.value(value)
-
- def value(self, v=None):
- "Returns or sets the value of the property."
- if v != None:
- if isinstance(v, StringType): # Is a URI
- self._desc['value']=v
- Property.value_type(self, 'URI')
- else:
- try:
- tempStr = v.read()
- except:
- raise TypeError,"%s must be a URL string or file-ish type"\
- % str(v)
- self._desc['value'] = base64.encodestring(tempStr)
- Property.value_type(self, 'BINARY')
- else:
- return self._desc['value']
-
- def name(self):
- "Returns the name of the property."
- return Property.name(self)
-
- def value_type(self):
- return Property.value_type(self)
-
- def fmttype(self, v=None):
- "Gets or sets the FMTYPE parameter."
- if v!= None:
- self['FMTTYPE']=v
- else:
- return self['FMTTYPE']
-
diff --git a/libical/src/python/Duration.py b/libical/src/python/Duration.py
deleted file mode 100644
index e6c642a8f7..0000000000
--- a/libical/src/python/Duration.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Duration.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#===============================================================
-
-from LibicalWrap import *
-from Property import Property
-from types import DictType, StringType, IntType
-
-class Duration(Property):
- """
- Represent a length of time, like 3 minutes, or 6 days, 20 seconds.
-
-
- """
-
- def __init__(self, arg, name="DURATION"):
- """
- Create a new duration from an RFC2445 string or number of seconds.
- Construct the duration from an iCalendar string or a number of seconds.
-
- Duration("P3DT2H34M45S") Construct from an iCalendar string
- Duration(3660) Construct from seconds
- """
-
- self.dur = None
-
- e=icalerror_supress("MALFORMEDDATA")
-
- if isinstance(arg, DictType):
-
- self.dur = icaldurationtype_from_string(arg['value'])
- Property.__init__(self,ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
- self.dur = icaldurationtype_from_string(arg)
- elif isinstance(arg, IntType):
- self.dur = icaldurationtype_from_int(arg)
- elif isinstance(arg,Duration):
- self.dur = arg.dur
- else:
- self.dur = icaldurationtype_null_duration()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e)
-
- if self.dur == None or icaldurationtype_is_null_duration(self.dur):
- raise Property.ConstructorFailedError("Failed to construct Duration from " +str(arg))
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct Duration from " + str(arg))
-
- def _update_value(self):
-
- self.value(icaldurationtype_as_ical_string(self.dur),"DURATION")
-
- def valid(self):
- "Return true if this is a valid duration"
-
- return not icaldurationtype_is_null_duration(self.dur)
-
- def seconds(self,v=None):
- """Return or set duration in seconds"""
- if(v != None):
- self.dur = icaldurationtype_from_int(v);
- self.dict['value'] = icaltimedurationtype_as_ical_string(self.dur)
- return icaldurationtype_as_int(self.dur)
diff --git a/libical/src/python/Error.py b/libical/src/python/Error.py
deleted file mode 100644
index 912553d14e..0000000000
--- a/libical/src/python/Error.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-class LibicalError(Exception):
- "Libical Error"
-
- def __init__(self,str):
- Exception.__init__(self,str)
-
- def __str__(self):
- return Exception.__str__(self)+"\nLibical errno: "+icalerror_perror()
diff --git a/libical/src/python/Gauge.py b/libical/src/python/Gauge.py
deleted file mode 100644
index ec859055fb..0000000000
--- a/libical/src/python/Gauge.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Gauge.py
-# CREATOR: mtearle
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-from Error import LibicalError
-from Component import Component
-
-class Gauge:
- """
- Base class for gauge
- """
-
- class ConstructorFailedError(LibicalError):
- "Failed to create a Guage "
-
- class CloneFailedError(LibicalError):
- "Failed to clone a component given Gauge "
-
- class CompareFailedError(LibicalError):
- "Failed to compare a component given Gauge "
-
- def __init__(self,ref=None,sql=None,expand=0):
- if ref != None:
- self._ref = ref
- elif sql != None:
- s = str(sql)
- self._ref = icalgauge_new_from_sql(s,expand)
- else:
- Gauge.ConstructorFailedError("No SQL Specified")
-
- def __del__(self):
- if self._ref != None:
- icalgauge_free(self._ref)
- self._ref = None
-
- def ref(self):
- return self._ref
-
- def compare(self, comp):
- if not isinstance(comp,Component):
- raise Gauge.CompareFailedError("Argument is not a component")
-
- if comp.ref() == None:
- raise Gauge.CompareFailedError("Argument is not a component")
-
- return icalgauge_compare(self._ref, comp.ref())
-
- # Pending Implementation
- #def as_sql_string(self):
- # return self.__str__()
-
- #def __str__(self):
- # return icalgauge_as_sql(self._ref)
-
- #def clone(self, comp):
-# if not isinstance(comp,Component):
-# raise Gauge.CloneFailedError("Argument is not a component")
-#
-# comp_ref = icalgauge_new_clone(self._ref, comp)
-#
-# if comp_ref == None:
-# return None
-#
-# return Component(ref=comp_ref)
diff --git a/libical/src/python/Libical.py b/libical/src/python/Libical.py
deleted file mode 100644
index 9cf5076520..0000000000
--- a/libical/src/python/Libical.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Libical.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from Component import Component, NewComponent, Event, Todo, Journal
-from Property import Property, RecurrenceSet, test_enum
-from Time import Time
-from Period import Period
-from Duration import Duration
-from Attendee import Attendee, Organizer
-from DerivedProperties import RDate, Trigger,Recurrence_Id, Attach
-from Store import Store, FileStore
-from Gauge import Gauge
diff --git a/libical/src/python/LibicalWrap.i b/libical/src/python/LibicalWrap.i
deleted file mode 100644
index bf3e19c1d9..0000000000
--- a/libical/src/python/LibicalWrap.i
+++ /dev/null
@@ -1,453 +0,0 @@
-/* -*- Mode: C -*-*/
-/*======================================================================
- FILE: ical.i
-
- (C) COPYRIGHT 1999 Eric Busboom
- http://www.softwarestudio.org
-
- The contents of this file are subject to the Mozilla Public License
- Version 1.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.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- the License for the specific language governing rights and
- limitations under the License.
-
- The original author is Eric Busboom
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
- ======================================================================*/
-
-%module LibicalWrap
-
-
-%{
-#include "ical.h"
-#include "icalss.h"
-
-#include <sys/types.h> /* for size_t */
-#include <time.h>
-
-%}
-
-
-#include "fcntl.h" /* For Open flags */
-
-typedef void icalcomponent;
-typedef void icalproperty;
-
-icalcomponent* icalparser_parse_string(char* str);
-
-
-/* actually takes icalcomponent_kind */
-icalcomponent* icalcomponent_new(int kind);
-icalcomponent* icalcomponent_new_clone(icalcomponent* component);
-icalcomponent* icalcomponent_new_from_string(char* str);
-
-const char* icalcomponent_kind_to_string(int kind);
-int icalcomponent_string_to_kind(const char* string);
-
-
-char* icalcomponent_as_ical_string(icalcomponent* component);
-
-void icalcomponent_free(icalcomponent* component);
-int icalcomponent_count_errors(icalcomponent* component);
-void icalcomponent_strip_errors(icalcomponent* component);
-void icalcomponent_convert_errors(icalcomponent* component);
-
-icalproperty* icalcomponent_get_current_property(icalcomponent* component);
-
-icalproperty* icalcomponent_get_first_property(icalcomponent* component,
- int kind);
-icalproperty* icalcomponent_get_next_property(icalcomponent* component,
- int kind);
-
-icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
-
-icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
- int kind);
-icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
- int kind);
-
-void icalcomponent_add_property(icalcomponent* component,
- icalproperty* property);
-
-void icalcomponent_remove_property(icalcomponent* component,
- icalproperty* property);
-
-
-void icalcomponent_add_component(icalcomponent* parent,
- icalcomponent* child);
-
-void icalcomponent_remove_component(icalcomponent* parent,
- icalcomponent* child);
-
-icalcomponent* icalcomponent_get_inner(icalcomponent* comp);
-
-icalcomponent* icalcomponent_get_parent(icalcomponent* component);
-int icalcomponent_isa(icalcomponent* component);
-
-int icalrestriction_check(icalcomponent* comp);
-
-/* actually takes icalproperty_kind */
-icalproperty* icalproperty_new(int kind);
-
-icalproperty* icalproperty_new_from_string(char* str);
-
-char* icalproperty_as_ical_string(icalproperty *prop);
-
-void icalproperty_set_parameter_from_string(icalproperty* prop,
- const char* name, const char* value);
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
- const char* name);
-void icalproperty_remove_parameter_by_name(icalproperty* prop,
- const char *name);
-
-void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char * kind);
-
-const char* icalproperty_get_value_as_string(icalproperty* prop);
-icalcomponent* icalproperty_get_parent(icalproperty* property);
-
-const char* icalproperty_kind_to_string(int kind);
-int icalproperty_string_to_kind(const char* string);
-int icalproperty_string_to_enum(const char* str);
-int icalproperty_enum_belongs_to_property(int kind, int e);
-int icalproperty_kind_to_value_kind(int kind);
-
-/* Deal with X properties */
-
-void icalproperty_set_x_name(icalproperty* prop, const char* name);
-const char* icalproperty_get_x_name(icalproperty* prop);
-
-/* Return the name of the property -- the type name converted to a
- string, or the value of _get_x_name if the type is and X property */
-const char* icalproperty_get_name (const icalproperty* prop);
-
-
-int icalerror_supress(const char* error);
-void icalerror_restore(const char* error, int es);
-char* icalerror_perror();
-void icalerror_clear_errno(void);
-
-
-const char* icalvalue_kind_to_string(int kind);
-int icalvalue_string_to_kind(const char* str);
-
-char* icalparameter_as_ical_string(icalparameter* parameter);
-
-const char* icalparameter_kind_to_string(int kind);
-int icalparameter_string_to_kind(const char* string);
-
-int* icallangbind_new_array(int size);
-void icallangbind_free_array(int* array);
-int icallangbind_access_array(int* array, int index);
-
-
-
-/* int icalrecur_expand_recurrence(char* rule, int start,
- int count, int* array);*/
-int icalrecur_expand_recurrence(char* rule, int start,
- int count, time_t* array);
-
-
-/* Iterate through properties, components and parameters using strings for the kind */
-icalproperty* icallangbind_get_first_property(icalcomponent *c,
- const char* prop);
-
-icalproperty* icallangbind_get_next_property(icalcomponent *c,
- const char* prop);
-
-icalcomponent* icallangbind_get_first_component(icalcomponent *c,
- const char* comp);
-
-icalcomponent* icallangbind_get_next_component(icalcomponent *c,
- const char* comp);
-
-icalparameter* icallangbind_get_first_parameter(icalproperty *prop);
-
-icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
-
-
-/* Return a string that can be evaluated in perl or python to
- generated a hash that holds the property's name, value and
- parameters. Sep is the hash seperation string, "=>" for perl and
- ":" for python */
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
-
-int icallangbind_string_to_open_flag(const char* str);
-
-const char* icallangbind_quote_as_ical(const char* str);
-
-/***********************************************************************
- Time routines
-***********************************************************************/
-
-
-struct icaltimetype
-{
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
-};
-
-
-/* Convert seconds past UNIX epoch to a timetype*/
-struct icaltimetype icaltime_from_timet(int v, int is_date);
-
-/** Convert seconds past UNIX epoch to a timetype, using timezones. */
-struct icaltimetype icaltime_from_timet_with_zone(int tm,
- int is_date, icaltimezone *zone);
-
-/* Return the time as seconds past the UNIX epoch */
-/* Normally, this returns a time_t, but SWIG tries to turn that type
- into a pointer */
-int icaltime_as_timet(struct icaltimetype tt);
-
-/* Return a string represention of the time, in RFC2445 format. The
- string is owned by libical */
-char* icaltime_as_ical_string(struct icaltimetype tt);
-
-/* create a time from an ISO format string */
-struct icaltimetype icaltime_from_string(const char* str);
-
-/* Routines for handling timezones */
-/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */
-struct icaltimetype icaltime_null_time(void);
-
-/* Return true of the time is null. */
-int icaltime_is_null_time(struct icaltimetype t);
-
-/* Returns false if the time is clearly invalid, but is not null. This
- is usually the result of creating a new time type buy not clearing
- it, or setting one of the flags to an illegal value. */
-int icaltime_is_valid_time(struct icaltimetype t);
-
-/** @brief Return the timezone */
-const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
-
-/** @brief Return the tzid, or NULL for a floating time */
-char *icaltime_get_tzid(const struct icaltimetype t);
-
-/** @brief Set the timezone */
-struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
- const icaltimezone *zone);
-
-/* Returns true if time is of DATE type, false if DATE-TIME */
-int icaltime_is_date(struct icaltimetype t);
-
-/* Returns true if time is relative to UTC zone */
-int icaltime_is_utc(struct icaltimetype t);
-
-/* Reset all of the time components to be in their normal ranges. For
- instance, given a time with minutes=70, the minutes will be reduces
- to 10, and the hour incremented. This allows the caller to do
- arithmetic on times without worrying about overflow or
- underflow. */
-struct icaltimetype icaltime_normalize(struct icaltimetype t);
-
-/* Return the day of the year of the given time */
-short icaltime_day_of_year(struct icaltimetype t);
-
-/* Create a new time, given a day of year and a year. */
-struct icaltimetype icaltime_from_day_of_year(short doy, short year);
-
-/* Return the day of the week of the given time. Sunday is 0 */
-short icaltime_day_of_week(struct icaltimetype t);
-
-/* Return the day of the year for the Sunday of the week that the
- given time is within. */
-short icaltime_start_doy_of_week(struct icaltimetype t);
-
-/* Return the week number for the week the given time is within */
-short icaltime_week_number(struct icaltimetype t);
-
-/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
-int icaltime_compare(struct icaltimetype a,struct icaltimetype b);
-
-/* like icaltime_compare, but only use the date parts. */
-int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b);
-
-/* Return the number of days in the given month */
-short icaltime_days_in_month(short month,short year);
-
-/** convert tt, of timezone tzid, into a utc time. Does nothing if the
- time is already UTC. */
-struct icaltimetype icaltime_convert_to_zone(struct icaltimetype tt,
- icaltimezone *zone);
-
-
-
-/***********************************************************************
- Duration Routines
-***********************************************************************/
-
-
-struct icaldurationtype
-{
- int is_neg;
- unsigned int days;
- unsigned int weeks;
- unsigned int hours;
- unsigned int minutes;
- unsigned int seconds;
-};
-
-struct icaldurationtype icaldurationtype_from_int(int t);
-struct icaldurationtype icaldurationtype_from_string(const char*);
-int icaldurationtype_as_int(struct icaldurationtype duration);
-char* icaldurationtype_as_ical_string(struct icaldurationtype d);
-struct icaldurationtype icaldurationtype_null_duration();
-int icaldurationtype_is_null_duration(struct icaldurationtype d);
-
-struct icaltimetype icaltime_add(struct icaltimetype t,
- struct icaldurationtype d);
-
-struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
- struct icaltimetype t2);
-
-
-/***********************************************************************
- Period Routines
-***********************************************************************/
-
-
-struct icalperiodtype
-{
- struct icaltimetype start;
- struct icaltimetype end;
- struct icaldurationtype duration;
-};
-
-struct icalperiodtype icalperiodtype_from_string (const char* str);
-
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
-struct icalperiodtype icalperiodtype_null_period();
-int icalperiodtype_is_null_period(struct icalperiodtype p);
-int icalperiodtype_is_valid_period(struct icalperiodtype p);
-
-/***********************************************************************
- * timezone handling routines
-***********************************************************************/
-
-/** Returns a single builtin timezone, given its Olson city name. */
-icaltimezone* icaltimezone_get_builtin_timezone (const char *location);
-
-/** Returns the UTC timezone. */
-icaltimezone* icaltimezone_get_utc_timezone (void);
-
-/***********************************************************************
- Storage Routines
-***********************************************************************/
-
-/**
- * @brief options for opening an icalfileset.
- *
- * These options should be passed to the icalset_new() function
- */
-
-struct icalfileset_options {
- int flags; /**< flags for open() O_RDONLY, etc */
- mode_t mode; /**< file mode */
- icalcluster *cluster; /**< use this cluster to initialize data */
-};
-
-icalset* icalfileset_new(const char* path);
-icalset* icalfileset_new_reader(const char* path);
-icalset* icalfileset_new_writer(const char* path);
-
-icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
-
-/* icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster); */
-
-icalcluster* icalfileset_produce_icalcluster(const char *path);
-
-void icalfileset_free(icalset* cluster);
-
-const char* icalfileset_path(icalset* cluster);
-
-/* Mark the cluster as changed, so it will be written to disk when it
- is freed. Commit writes to disk immediately. */
-void icalfileset_mark(icalset* set);
-icalerrorenum icalfileset_commit(icalset* set);
-
-icalerrorenum icalfileset_add_component(icalset* set,
- icalcomponent* child);
-
-icalerrorenum icalfileset_remove_component(icalset* set,
- icalcomponent* child);
-
-int icalfileset_count_components(icalset* set,
- int kind);
-
-/**
- * Restrict the component returned by icalfileset_first, _next to those
- * that pass the gauge. _clear removes the gauge
- */
-icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
-
-/** clear the gauge **/
-void icalfileset_clear(icalset* set);
-
-/** Get and search for a component by uid **/
-icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
-int icalfileset_has_uid(icalset* set, const char* uid);
-icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
-
-
-/**
- * Modify components according to the MODIFY method of CAP. Works on the
- * currently selected components.
- */
-icalerrorenum icalfileset_modify(icalset* set,
- icalcomponent *oldcomp,
- icalcomponent *newcomp);
-
-/* Iterate through components. If a gauge has been defined, these
- will skip over components that do not pass the gauge */
-
-icalcomponent* icalfileset_get_current_component (icalset* cluster);
-icalcomponent* icalfileset_get_first_component(icalset* cluster);
-icalcomponent* icalfileset_get_next_component(icalset* cluster);
-
-/* External iterator for thread safety */
-icalsetiter icalfileset_begin_component(icalset* set, int kind, icalgauge* gauge);
-icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
-icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
-
-/***********************************************************************
- Gauge Routines
-***********************************************************************/
-
-icalgauge* icalgauge_new_from_sql(char* sql, int expand);
-
-int icalgauge_get_expand(icalgauge* gauge);
-
-void icalgauge_free(icalgauge* gauge);
-
-/* Pending Implementation */
-/* char* icalgauge_as_sql(icalcomponent* gauge); */
-
-void icalgauge_dump(icalgauge* gauge);
-
-
-/** @brief Return true if comp matches the gauge.
- *
- * The component must be in
- * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
- * sub component
- */
-int icalgauge_compare(icalgauge* g, icalcomponent* comp);
-
-/* Pending Implementation */
-/** Clone the component, but only return the properties
- * specified in the gauge */
-/* icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); */
-
-
diff --git a/libical/src/python/Makefile.am b/libical/src/python/Makefile.am
deleted file mode 100644
index e221fa91c1..0000000000
--- a/libical/src/python/Makefile.am
+++ /dev/null
@@ -1,48 +0,0 @@
-
-lib_LTLIBRARIES = libLibicalWrap.la
-
-libLibicalWrap_la_SOURCES = LibicalWrap.c
-
-INCLUDES = \
- -I$(top_builddir) \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -I$(top_srcdir)/src/libical \
- -I$(top_builddir)/src/libical \
- -I$(top_srcdir)/src/libicalss \
- $(PY_CFLAGS)
-
-LDADD = ../libical/libical.la ../libicalss/libicalss.la
-
-all: LibicalWrap.so
-
-LibicalWrap.c: LibicalWrap.i
- swig -python -o LibicalWrap.c LibicalWrap.i
-
-# This part should be done with libtool, but I don't know how to do
-# it. Libtool needs to generate a shared library in this directory
-# regardless of the value of AM_DISABLE_SHARED
-LibicalWrap.so: LibicalWrap.c
- ld -shared -o LibicalWrap.so LibicalWrap.o ../libical/.libs/libical.a ../libicalss/.libs/libicalss.a
-
-CLEANFILES = LibicalWrap.c LibicalWrap_wrap.doc Libical.pyc LibicalWrap.so
-
-EXTRA_DIST = \
-Libical.py \
-LibicalWrap.i \
-python-binding.txt \
-test.py \
-Attendee.py \
-Collection.py \
-Component.py \
-DerivedProperties.py \
-Duration.py \
-Error.py \
-Gauge.py \
-Period.py \
-Property.py \
-Store.py \
-Time.py \
-ChangeLog
-
-
diff --git a/libical/src/python/Period.py b/libical/src/python/Period.py
deleted file mode 100644
index e8d9b3ed40..0000000000
--- a/libical/src/python/Period.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Period.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#===========================================================
-
-from LibicalWrap import *
-from Property import Property
-from types import DictType, StringType, IntType
-from Time import Time
-from Duration import Duration
-
-class Period(Property):
- """Represent a span of time"""
- def __init__(self,arg,name='FREEBUSY'):
- """ """
-
- Property.__init__(self, type = name)
-
- self.pt=None
-
- #icalerror_clear_errno()
- e1=icalerror_supress("MALFORMEDDATA")
- e2=icalerror_supress("BADARG")
-
- if isinstance(arg, DictType):
-
-
- es=icalerror_supress("MALFORMEDDATA")
- self.pt = icalperiodtype_from_string(arg['value'])
- icalerror_restore("MALFORMEDDATA",es)
-
- Property.__init__(self, ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
-
- self.pt = icalperiodtype_from_string(arg)
-
- else:
- self.pt = icalperiodtype_null_period()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e1)
- icalerror_restore("BADARG",e2)
-
-
- if self.pt == None or icalperiodtype_is_null_period(self.pt):
- raise Property.ConstructorFailedError("Failed to construct Period")
-
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct Period")
-
- def _end_is_duration(self):
- dur = icalperiodtype_duration_get(self.pt)
- if not icaldurationtype_is_null_duration(dur):
- return 1
- return 0
-
- def _end_is_time(self):
- end = icalperiodtype_end_get(self.pt)
- if not icaltime_is_null_time(end):
- return 1
- return 0
-
- def _update_value(self):
-
- self.value(icalperiodtype_as_ical_string(self.pt),"PERIOD")
-
-
- def valid(self):
- "Return true if this is a valid period"
-
- return not icalperiodtype_is_null_period(self.dur)
-
- def start(self,v=None):
- """
- Return or set start time of the period. The start time may be
- expressed as an RFC2445 format string or an instance of Time.
- The return value is an instance of Time
- """
-
- if(v != None):
- if isinstance(t,Time):
- t = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- t = Time(v,"DTSTART")
- else:
- raise TypeError
-
- icalperiodtype_start_set(self.pt,t.tt)
-
- self._update_value()
-
-
- return Time(icaltime_as_timet(icalperiodtype_start_get(self.pt)),
- "DTSTART")
-
- def end(self,v=None):
- """
- Return or set end time of the period. The end time may be
- expressed as an RFC2445 format string or an instance of Time.
- The return value is an instance of Time.
-
- If the Period has a duration set, but not an end time, this
- method will caluculate the end time from the duration. """
-
- if(v != None):
-
- if isinstance(t,Time):
- t = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- t = Time(v)
- else:
- raise TypeError
-
- if(self._end_is_duration()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- dur = t.utc_seconds()-start;
- icalperiodtype_duration_set(self.pt,
- icaldurationtype_from_int(dur))
- else:
- icalperiodtype_end_set(self.pt,t.tt)
-
- self._update_value()
-
- if(self._end_is_time()):
- rt = Time(icaltime_as_timet(icalperiodtype_end_get(self.pt)),
- 'DTEND')
- rt.timezone(self.timezone())
- return rt
- elif(self._end_is_duration()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- dur = icaldurationtype_as_int(icalperiodtype_duration_get(self.pt))
- rt = Time(start+dur,'DTEND')
- rt.timezone(self.timezone())
- return rt
- else:
- return Time({},'DTEND')
-
-
-
- def duration(self,v=None):
- """
- Return or set the duration of the period. The duration may be
- expressed as an RFC2445 format string or an instance of Duration.
- The return value is an instance of Duration.
-
- If the period has an end time set, but not a duration, this
- method will calculate the duration from the end time. """
-
- if(v != None):
-
- if isinstance(t,Duration):
- d = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- d = Duration(v)
- else:
- raise TypeError
-
- if(self._end_is_time()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- end = start + d.seconds()
-
- icalperiodtype_end_set(self.pt,icaltime_from_timet(end,0))
- else:
- icalperiodtype_duration_set(self.pt,d.dur)
-
- if(self._end_is_time()):
- start =icaltime_as_timet(icalperiodtype_start_get(self.pt))
- end = icaltime_as_timet(icalperiodtype_end_get(self.pt))
-
- print "End is time " + str(end-start)
-
- return Duration(end-start,"DURATION")
-
- elif(self._end_is_duration()):
- dur = icaldurationtype_as_int(
- icalperiodtype_duration_get(self.pt))
-
- return Duration(dur,"DURATION")
- else:
-
-
- return Duration(0,"DURATION")
-
-
- def timezone(self,v=None):
- """ Return or set the timezone string for this time """
- if (v != None):
- self['TZID'] = v
- return self['TZID']
diff --git a/libical/src/python/Property.py b/libical/src/python/Property.py
deleted file mode 100644
index 80c5864855..0000000000
--- a/libical/src/python/Property.py
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Property.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-import re
-import base64
-from string import index, upper, split
-from types import StringType
-
-#def icalerror_supress(arg):
-# pass
-
-#def icalerror_restore(a,b):
-# pass
-
-def error_type():
- error = icalerror_perror()
- return error[:index(error,':')]
-
-def test_enum(prop,enum):
-
- kind = icalproperty_string_to_kind(prop)
- e = icalproperty_string_to_enum(enum)
-
- t = icalproperty_enum_belongs_to_property(kind,e)
-
- if t == 1:
- return 1
-
- return None
-
-
-class Property:
- """ Represent any iCalendar Property.
-
- Usage:
- Property(dict)
-
- Where:
- dict is a dictionary with keys of 'name', 'value_type', and 'value'.
- In addition, parameter:parameter value entries may be included.
- """
-
- class ConstructorFailedError(Exception):
- "Failed to construct a property"
-
- class UpdateFailedError(Exception):
- "Failed to update the value of a property"
-
-
- def __init__(self, type = None, ref = None):
-
-
- assert(ref == None or isinstance(ref,StringType))
- assert(type == None or isinstance(type,StringType))
-
- self._ref = None
-
- if ref != None:
- self._ref = ref
- elif type != None:
- kind = icalproperty_string_to_kind(type)
- self._ref = icalproperty_new(kind)
-
- if type.find("X-") == 0:
- icalproperty_set_x_name(self._ref, type)
-
- if self._ref == None or self._ref == 'NULL':
- raise Property.ConstructorFailedError("Failed to construct Property")
-
- self._deleted = 0;
-
-
- # Initialize all of the required keys
-
-
- def __del__(self):
-
- self._deleted = 1;
-
- if not self._deleted and \
- self.ref() and \
- icalproperty_get_parent(self.ref()) == 'NULL':
-
- icalproperty_free(self.ref())
-
- def name(self,v=None):
- """ Return the name of the property """
- return icalproperty_get_name(self._ref)
-
- def ref(self,v=None):
- """ Return the internal reference to the libical icalproperty """
- if(v != None):
-
- if not self._deleted and self._ref and \
- icalproperty_get_parent(self._ref) == 'NULL':
-
- icalproperty_free(self._ref)
-
- self._ref = v
-
- return self._ref
-
-
- def value(self,v=None, kind = None):
- """ Return the RFC2445 representation of the value """
-
- if(v != None):
-
- if kind != None:
- # Get the default kind of value for this property
- default_kind = icalvalue_kind_to_string(icalproperty_kind_to_value_kind(icalproperty_string_to_kind(self.name())))
-
- if(kind != default_kind):
- self.__setitem__('VALUE',kind)
- vt = kind
- elif self.__getitem__('VALUE'):
- vt = self.__getitem__('VALUE')
- print "###########", self
- else:
- vt = 'NO' # Use the kind of the existing value
-
-
- icalerror_clear_errno()
-
- #e1=icalerror_supress("MALFORMEDDATA")
- if (self.name().find("X-") == 0) and type(v) is StringType:
- v = icallangbind_quote_as_ical(v)
- v = icallangbind_quote_as_ical(v)
-
- icalproperty_set_value_from_string(self._ref,str(v),vt)
- #icalerror_restore("MALFORMEDDATA",e1)
-
- if error_type() != "NO":
- raise Property.UpdateFailedError(error_type())
-
- s = icalproperty_get_value_as_string(self._ref)
-
- return icalproperty_get_value_as_string(self._ref)
-
- def parameters(self):
- """
- Return a list of parameters
- """
-
- params = []
-
- p = icallangbind_get_first_parameter(self._ref)
-
- while p != None:
- kv = split(icalparameter_as_ical_string(p),'=',2)
- params.append(kv[0])
- p = icallangbind_get_next_parameter(self._ref)
-
- return params
-
- def as_ical_string(self):
- "Return the property in iCalendar text format."
- return icalproperty_as_ical_string(self._ref)
-
- def __getitem__(self,key):
- """ Return property values by name """
- key = upper(key)
- str = icalproperty_get_parameter_as_string(self._ref,key)
-
- if(str == 'NULL'): return None
-
- return str
-
- def __setitem__(self,key,value):
- """ Set Property Values by Name """
- key = upper(key)
-
- icalproperty_set_parameter_from_string(self._ref,key,value)
-
- return self.__getitem__(key)
-
- def __delitem__(self,key):
- """ Remove Property Values by Name """
- key = upper(key)
-
- if self.__getitem__(key):
- icalproperty_remove_parameter_by_name(self._ref,key)
-
- def __str__(self):
-
- str = self.as_ical_string()
- return re.sub('\r?\n ?','',str)
-
- def __cmp__(self, other):
- s_str = str(self)
- o_str = str(other)
-
- return cmp(s_str,o_str)
-
-
-class RecurrenceSet:
- """
- Represents a set of event occurrences. This
- class controls a component's RRULE, EXRULE, RDATE and EXDATE
- properties and can produce from them a set of occurrences.
- """
-
- def __init__(self):
- pass
-
- def include(self, **params):
- """
- Include a date or rule to the set.
-
- Use date= or pass in a
- Time instance to include a date. Included dates will add an
- RDATE property or will remove an EXDATE property of the same
- date.
-
- Use rule= or pass in a string to include a rule. Included
- rules with either add a RRULE property or remove an EXRULE
- property.
-
- """
- pass
-
- def exclude(self, **params):
- """
- Exclude date or rule to the set.
-
- Use date= or pass in a Time instance to exclude a
- date. Excluded dates will add an EXDATE property or will remove
- an RDATE property of the same date.
-
- Use rule= or pass in a string to exclude a rule. Excluded
- rules with either add an EXRULE property or remove an RRULE
- property.
-
- """
- pass
-
- def occurrences(self, count=None):
- """
- Return 'count' occurrences as a tuple of Time instances.
- """
- pass
-
-
diff --git a/libical/src/python/Store.py b/libical/src/python/Store.py
deleted file mode 100644
index 00b5b0c2d0..0000000000
--- a/libical/src/python/Store.py
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Store.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-from Error import LibicalError
-from Component import Component, CloneComponent
-from Gauge import Gauge
-
-class Store:
- """
- Base class for several component storage methods
- """
-
- class AddFailedError(LibicalError):
- "Failed to add a property to the file store"
-
- class ConstructorFailedError(LibicalError):
- "Failed to create a Store "
-
- def __init__(self):
- pass
-
- def path(self):
- pass
-
- def mark(self):
- pass
-
- def commit(self):
- pass
-
- def add_component(self, comp):
- pass
-
- def remove_component(self, comp):
- pass
-
- def count_components(self, kind):
- pass
-
- def select(self, gauge):
- pass
-
- def clearSelect(self):
- pass
-
- def fetch(self, uid):
- pass
-
- def fetchMatch(self, comp):
- pass
-
- def modify(self, oldc, newc):
- pass
-
- def current_component(self):
- pass
-
- def first_component(self):
- pass
-
- def next_component(self):
- pass
-
-
-class FileStore(Store):
-
- def __init__(self, file):
- e1=icalerror_supress("FILE")
- self._ref = icalfileset_new(file)
- icalerror_restore("FILE",e1)
-
- if self._ref == None or self._ref == 'NULL':
- raise Store.ConstructorFailedError(file)
-
- def __del__(self):
- icalfileset_free(self._ref)
-
- def path(self):
- return icalfileset_path(self._ref)
-
- def mark(self):
- icalfileset_mark(self._ref)
-
- def commit(self):
- icalfileset_commit(self._ref)
-
- def add_component(self, comp):
- if not isinstance(comp,Component):
- raise Store.AddFailedError("Argument is not a component")
-
- error = icalfileset_add_component(self._ref,comp.ref())
-
- def remove_component(self, comp):
- if not isinstance(comp,Component):
- raise Store.AddFailedError("Argument is not a component")
-
- error = icalfileset_remove_component(self._ref,comp.ref())
-
- def count_components(self, kind):
- _kind = icalcomponent_string_to_kind(kind)
-
- return icalfileset_count_components(self._ref, _kind)
-
- def select(self, gauge):
- error = icalfileset_select(self._ref, gauge.ref())
-
- def clearSelect(self):
- icalfileset_clear(self._ref)
-
- def fetch(self, uid):
- comp_ref = icalfileset_fetch(self._ref, uid)
-
- if comp_ref == None:
- return None
-
- return CloneComponent(comp_ref)
-
- def fetchMatch(self, comp):
- if not isinstance(comp,Component):
- raise Store.AddFailedError("Argument is not a component")
-
- comp_ref = icalfileset_fetch_match(self._ref,comp.ref())
-
- if comp_ref == None:
- return None
-
- return CloneComponent(comp_ref)
-
- def modify(self, oldc, newc):
- pass
-
- def current_component(self):
- comp_ref = icalfileset_get_current_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return CloneComponent(comp_ref)
-
- def first_component(self):
- comp_ref = icalfileset_get_first_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return CloneComponent(comp_ref)
-
- def next_component(self):
-
- comp_ref = icalfileset_get_next_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return CloneComponent(comp_ref)
-
diff --git a/libical/src/python/Time.py b/libical/src/python/Time.py
deleted file mode 100644
index 673607d7b4..0000000000
--- a/libical/src/python/Time.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Time.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-from LibicalWrap import *
-from Property import Property
-from types import DictType, StringType, IntType, FloatType
-from Duration import Duration
-
-class Time(Property):
- """ Represent iCalendar DATE, TIME and DATE-TIME """
- def __init__(self, arg, name="DTSTART", zone=None):
- """
- Create a new Time from a string or number of seconds past the
- POSIX epoch
-
- Time("19970325T123000Z") Construct from an iCalendar string
- Time(8349873494) Construct from seconds past POSIX epoch
-
- """
- e1=icalerror_supress("MALFORMEDDATA")
- e2=icalerror_supress("BADARG")
-
- if isinstance(arg, DictType):
- # Dictionary -- used for creating from Component
- self.tt = icaltime_from_string(arg['value'])
- Property.__init__(self, ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
- # Create from an iCal string
- self.tt = icaltime_from_string(arg)
- elif isinstance(arg, IntType) or \
- isinstance(arg, FloatType):
- # Create from seconds past the POSIX epoch
- if zone:
- self.tt = icaltime_from_timet_with_zone(int(arg),0,icaltimezone_get_builtin_timezone(zone))
- else:
- self.tt = icaltime_from_timet_with_zone(int(arg),0,icaltimezone_get_utc_timezone())
- elif isinstance(arg, Time):
- # Copy an instance
- self.tt = arg.tt
- else:
- self.tt = icaltime_null_time()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e1)
- icalerror_restore("BADARG",e2)
-
- if icaltime_is_null_time(self.tt):
- raise Property.ConstructorFailedError("Failed to construct a Time")
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct a Time")
-
- def _update_value(self):
- self.tt = icaltime_normalize(self.tt)
- self.value(icaltime_as_ical_string(self.tt),"DATE-TIME")
-
- def valid(self):
- " Return true if this is a valid time "
- return not icaltime_is_null_time(self.tt)
-
- def utc_seconds(self,v=None):
- """ Return or set time in seconds past POSIX epoch"""
- if (v!=None):
- tz = icaltimezone_get_builtin_timezone(self.timezone())
- self.tt = icaltime_from_timet_with_zone(v,0,tz)
- self._update_value()
-
- return icaltime_as_timet(self.tt)
-
- def is_utc(self):
- """ Return a boolean indicating if time is in UTC """
- return icaltime_is_utc(self.tt)
-
- def is_date(self):
- """ Return a boolean indicating if time is actually a date """
- return icaltime_is_date(self.tt)
-
- def timezone(self,v=None):
- """ Return, set (if none) or alter the timezone for this time """
-
- origtz = icaltime_get_tzid(self.tt)
-
- if (v != None):
- assert(isinstance(v,StringType) )
- if (v == "UTC"):
- tz = icaltimezone_get_utc_timezone()
- del self['TZID']
- else:
- tz = icaltimezone_get_builtin_timezone(v)
-
- if not origtz:
- self.tt = icaltime_set_timezone(self.tt, tz)
- else:
- self.tt = icaltime_convert_to_zone(self.tt,tz)
-
- if (icaltime_get_tzid(self.tt) != "UTC"):
- self['TZID'] = icaltime_get_tzid(self.tt)
-
- self._update_value()
- return icaltime_get_tzid(self.tt)
-
- def second(self,v=None):
- """ Get or set the seconds component of this time """
- if(v != None):
- icaltimetype_second_set(self.tt,v)
- self._update_value()
- return icaltimetype_second_get(self.tt)
-
- def minute(self,v=None):
- """ Get or set the minute component of this time """
- if(v != None):
- icaltimetype_minute_set(self.tt,v)
- self._update_value()
- return icaltimetype_minute_get(self.tt)
-
- def hour(self,v=None):
- """ Get or set the hour component of this time """
- if(v != None):
- icaltimetype_hour_set(self.tt,v)
- self._update_value()
- return icaltimetype_hour_get(self.tt)
-
- def day(self,v=None):
- """ Get or set the month day component of this time """
- if(v != None):
- icaltimetype_day_set(self.tt,v)
- self._update_value()
- return icaltimetype_day_get(self.tt)
-
- def month(self,v=None):
- """ Get or set the month component of this time. January is month 1 """
- if(v != None):
- icaltimetype_month_set(self.tt,v)
- self._update_value()
- return icaltimetype_month_get(self.tt)
-
- def year(self,v=None):
- """ Get or set the year component of this time """
- if(v != None):
- icaltimetype_year_set(self.tt,v)
- self._update_value()
-
- return icaltimetype_year_get(self.tt)
-
-
- def __cmp__(self,other):
-
- if other == None:
- return cmp(self.utc_seconds(),None)
-
- return cmp(self.utc_seconds(),other.utc_seconds())
-
-
- def __add__(self,o):
-
- other = Duration(o,"DURATION")
-
- if not other.valid():
- return Duration(0,"DURATION")
-
- seconds = self.utc_seconds() + other.seconds()
-
- new = Time(seconds,self.name(),self.timezone())
-
- return new
-
- def __radd_(self,o):
- return self.__add__(o)
-
-
- def __sub__(self,o):
-
-
- if isinstance(o,Time):
- # Subtract a time from this time and return a duration
- seconds = self.utc_seconds() - other.utc_seconds()
- return Duration(seconds)
- elif isinstance(o,Duration):
- # Subtract a duration from this time and return a time
- other = Duration(o)
- if(not other.valid()):
- return Time()
-
- seconds = self.utc_seconds() - other.seconds()
- return Time(seconds)
- else:
- raise TypeError, "subtraction with Time reqires Time or Duration"
diff --git a/libical/src/python/littlefile.txt b/libical/src/python/littlefile.txt
deleted file mode 100644
index cba0891115..0000000000
--- a/libical/src/python/littlefile.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This is just a small file to test mime encoding.
-
-There isn't much here at all.
diff --git a/libical/src/python/python-binding.txt b/libical/src/python/python-binding.txt
deleted file mode 100644
index 7f925e246f..0000000000
--- a/libical/src/python/python-binding.txt
+++ /dev/null
@@ -1,434 +0,0 @@
-
-Classes for python binding to libical
-(Indentation indicates inheritance)
-
- Component
- Event
- JournalEntry
- Todo
- FreeBusy
- Timezone
- Alarm
- AudioAlarm
- EmailAlarm
- ProcedureAlarm
- DisplayAlarm
-
- Property
- Attendee
- Organizer
- Status
- Error
-
- Time
- Period
- Date
- RecurrenceSet
-
- Timezone
- TimezonePhase
-
- Store
- FileStore
- DirStore
- CAPStore
- HeapStore
- MySQLStore
-
-
-
-Component is the central class in the design. The component can be
-though of as a container for child components and properties, or as
-representation of a specific kind of iCal object. The first
-interface offers general property and component accessors, and the
-second treats some types of objects in a special way.
-
-The general interface offers simple manipulators for child property
-and components, and it only works with immediate children. So, given
-the Component:
-
- BEGIN:VCALENDAR
- METHOD:PUBLISH
- BEGIN:VEVENT
- BEGIN:VALARM
- COMMENT: An Alarm
- END:VALARM
- END:VEVENT
- END:VCALENDAR
-
-A caller would have to descend three levels to access the COMMENT
-property in the alarm, but only one to access the METHOD property.
-
-Libical is almost entirely dedicated to the general interface; it
-includes all of the *get_first_*, *_next_next_*, *_add_* and *_remove_*
-routines.
-
-The specific interface works with derived classes of Property and
-Component. In this interface, the caller could get the COMMENT in the
-alarm in the example in two steps. First the caller would ask the
-Event object for its alarms, then then the caller would ask the first
-Alarm object for its comment.
-
-The Specific interface is part of the
-derived classes of Component. This interface names all of the types of
-properties and components that can be accessed from the derived
-component type.
-
-In libical, the specific interface is primarily the "convenience
-routines in icalcomponent.h, such as:
-
-
- struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
- void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
-
- void icalcomponent_set_duration(icalcomponent* comp,
- struct icaldurationtype v);
- struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
-
-These routines are smarter and do more work than the general
-interface. From the general interface, you can set the DTEND
-property of a component by creating the property and adding it to a
-component. But, if the component already has a DURATION property, then
-this is an error -- a component can't have both.
-
-icalcomponent_set_dtend determines if the component already has a
-DURATION. If it does, it substracts the dtstart time from the new
-dtend time and sets the duration to that. Otherwise, it creates aor
-changes the DTEND.
-
-Also, icalcomponent_set_duration works the same regardless if the
-component is a VCALENDAR or a VEVENT. If it is a VCALENDAR, the
-routine descends into the VEVENT before making any changes. If it is
-allready a VEVENT ( or VTODO or VJOURNAL ) the routine just makes the
-changes. With icalcomponent_add_property, you need to do this check
-yourself.
-
-( There should probably be a class between Component
-and Event ,JournalEntry and Todo that names all of the properties and
-components. Then Event, JournalEntry and Todo would remove the
-accessors that did not apply to them. )
-
-Parameters are accessed as dictionaries from Property or as attributes
-of a derived class of Property. Both the names and the values of the
-parameters are strings.
-
-The Store hierarchy is a interface to various ways to store iCal
-components. Each of these has the same interface as its corresponding
-libical module:
-
- FileStore icalfileset Store iCal components in a single file
- DirStore icaldirset Use multiple files, one per month of
- DTSTART
- CAPStore Access components in a CAP server
- HeapStore Components stored in memory
- MySQLStore Components stored in a MySQL
- database.
-
-The only iCal value objects that will be implemented as Python classes
-are Time, Duration and Period. RecurrenceSet handles recurrence
-rules. It replaces the properties RRULE, RDATE, EXRULE and EXDATE.
-
-(Not all of the libical modules are implemented )
-
-
-How to Use the library
-----------------------
-
-The most common usecases will be something like this:
-
-1)Caller opens a Store object on a file, server or database. The
-caller retrieves one or more component. Some of the components will be
-booked on the user's calendar. Other components will be messages that
-other users have sent, like requests for meetings.
-
-2) The caller will use the Specific interface ( using methods specific
-to each property ) to example the component and decide what to do with
-it.
-
-3) Rarely, the caller will access the general interface to do things
-that the specific interface has not implemented or cannot manage
-well.
-
-4) Caller may create a new component, using a combination of the
-general and specific interfaces. The caller may send the message to
-another user via mail, or may submit it to the user's CAP server with
-the CAPStore class.
-
-
-Following are the methods in each of the classes.
-
-Component
- Construct from string
- Output string in ical form
-
- Get a Property by type
- Get a set of Properties by type
- Remove a Property by reference
-
- Get a Component by type
- Get a set of Components by type
- Remove a Component by reference
-
- Validate the component ( insert properties for errors )
- Count error properties
- Remove error properties
- Convert error properties into REQUEST-STATUS properties
-
-Event, JournalEntry, Todo
-
- Construct from string
- Output string in ical form
-
- There are get/set accessors for every property. These are
- listed in a later section
-
-
-FreeBusy
-
- Construct from string
- Construct from arguments
- Output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- method
- prodid
- attendee
- dtstamp
- dtstart
- freebusy
- organizer
- uid
- comment
- contact
- request-status
- url
- duration
- sequence
-
-TimezonePhase
-
- Construct from string
- Construct from arguments
- Output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- tzname
- offsetto
- offsetfrom
- rrule
- rdate
- comment
-
-TimeZone
-
- Construct from string
- Construct from arguments
- Output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- tzid
- last-modified
- tzurl
- standard (returns TimezonePhase)
- daylight (returns TimezonePhase)
-
-
-Property
-
- Construct from string
- Construct from arguments
- Output string in ical form
-
- Dictionary access to parameters
-
- Get/set value
-
-Attendee
-
- Construct from string
- Construct from arguments
- Output string in ical form
-
- Access to the following properties and parameters:
- cuid
- cutype
- member
- role
- rsvp
- delto
- delfrom
- sentby
- cn
- dir
- language
-
-Organizer
-
- Access to the following properties:
- common_name
- dir
- sentby
- language
-
-
-Time
-Date
-Period
-
- Same interfaces as libical modules.
-
-RecurenceSet
- I don't know -- need to think about it more.
-
-Store
- Similar methods to the icalset modules.
-
-
-RFC2445 Properties
-
-This is a list of all of the RFC2445 properties and their associated
-VALUE type.
-
-
-Property Value
-----------------------------
-CALSCALE TEXT
-METHOD TEXT
-PRODID TEXT
-VERSION TEXT
-CATEGORIES TEXT
-CLASS TEXT
-COMMENT TEXT
-DESCRIPTION TEXT
-LOCATION TEXT
-PERCENT-COMPLETE INTEGER
-PRIORITY INTEGER
-RESOURCES TEXT
-STATUS STATUS
-SUMMARY TEXT
-COMPLETED DATE-TIME
-FREEBUSY PERIOD
-TRANSP TEXT
-TZNAME TEXT
-TZOFFSETFROM UTC-OFFSET
-TZOFFSETTO UTC-OFFSET
-TZURL URI
-TZID TEXT
-ATTENDEE CAL-ADDRESS
-CONTACT TEXT
-ORGANIZER CAL-ADDRESS
-RELATED-TO TEXT
-URL URI
-UID TEXT
-EXRULE RECUR
-RRULE RECUR
-ACTION TEXT
-REPEAT INTEGER
-CREATED DATE-TIME
-DTSTAMP DATE-TIME
-LAST-MODIFIED DATE-TIME
-SEQUENCE INTEGER
-X TEXT
-REQUEST-STATUS STRING
-ATTACH URL, BINARY
-GEO FLOAT
-DTEND DATE-TIME
-DUE DATE-TIME
-DTSTART DATE-TIME
-RECURRENCE-ID DATE-TIME
-EXDATE DATE-TIME
-RDATE DATE-TIME, PERIOD
-TRIGGER DATE-TIME, DURATION
-DURATION DURATION
-
-Some of the properties can appear multiple times in a component, other
-can appear only once. For a particular component, the number of times
-a property can apper may also change with the METHOD property
-associated with the component. This list shows which properties can
-appear multiple times for some ( but not all ) combinations of
-component type and METHOD value:
-
-ATTACH
-ATTENDEE
-CATEGORIES
-COMMENT
-CONTACT
-EXDATE
-EXRULE
-FREEBUSY
-NONE
-RDATE
-RELATEDTO
-REQUESTSTATUS
-RESOURCES
-RRULE
-TZNAME
-TZURL
-X
-
-
-This is a list of the value types and their associated python return
-types. A lowercased return type is a python builtin, and an
-uppercase-first-letter is a class in the library:
-
-
-Value Return Type
------------------------------------
-BINARY file
-BOOLEAN number
-CAL-ADDRESS string
-DATE Time
-DATE-TIME Time
-DURATION Duration
-FLOAT number
-GEO tuple
-INTEGER number
-METHOD string
-PERIOD Period
-RECUR RecurrenceSet
-TEXT string
-TIME Time
-URI string
-UTC-OFFSET number
-STATUS string
-X string
-
-
-I suspect that the Component class should use the three previous
-tables to create the property accessor methods on the fly. If the
-method generation system is general enough, we could also use it for
-other classes, such as Alarm, Timezone, Attendee, Organizer and
-Freebusy.
-
-
-Memory Handling
----------------
-
-One of the things that made the perl binding to libcal difficult was
-that if a Component (in perl) returns a reference to a child Component
-(in perl), the child Component (in perl) will contain a reference to a
-libical component. When the caller is done with the child component in
-perl, the caller just drops it and lets perl reclaim the memory.
-
-The destructor for Component needs to free the libical component that
-it holds a reference to, but the child's libical component is still
-being used by libical. So perl frees the libical component and later,
-libical tries to reference freed memory.
-
-The situation is actually a little better than that, because libical
-will throw an error when you try to free a component that is still
-attached to a parent.
-
-So, the perl library has to be able to determine when the destructor
-should free a libical component or not. The perl library calls
-icalcomponent_get_parent(), and if is it non-zero, it does not free
-the component.
-
-It is not hard, just more code, and something to watch out for.
-
diff --git a/libical/src/python/test.py b/libical/src/python/test.py
deleted file mode 100644
index 4047e78c95..0000000000
--- a/libical/src/python/test.py
+++ /dev/null
@@ -1,603 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: test.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
-#
-# The LGPL as published by the Free Software Foundation, version
-# 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-#
-# Or:
-#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#======================================================================
-
-import LibicalWrap
-from Libical import *
-
-def error_type():
- error = icalerror_perror()
- return error[:index(error,':')]
-
-comp_str = """
-BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//ABC Corporation//NONSGML My Product//EN
-METHOD:REQUEST
-BEGIN:VEVENT
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com
-COMMENT: When in the course of writting comments and nonsense text\, it
- becomes necessary to insert a newline
-DTSTART:19972512T120000
-DTSTART:19970101T120000Z
-DTSTART:19970101
-DURATION:P3DT4H25M
-FREEBUSY:19970101T120000/19970101T120000
-FREEBUSY:19970101T120000/PT3H
-FREEBUSY:19970101T120000/PT3H
-END:VEVENT
-END:VCALENDAR"""
-
-
-def test_property():
-
- print "--------------------------- Test Property ----------------------"
-
-
- liw = LibicalWrap
- icalprop = liw.icalproperty_new_from_string("ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com")
-
- print liw.icalproperty_as_ical_string(icalprop)
-
- p = Property(ref=icalprop)
-
- print p.name()
- print
- print "Parameters:"
- for param in p.parameters():
- print " ", param, " = ", p[param]
- print
- print p['ROLE']
-
- p['ROLE'] = 'INDIVIDUAL'
-
- print p['ROLE']
-
- p['ROLE'] = 'GROFROMBLATZ'
-
- print p['ROLE']
-
- print
-
- p['X-MAN-FAVOURITE'] = 'Wolverine'
- p['X-FILES-FAVOURITE'] = 'Mulder'
-
- print p['X-MAN-FAVOURITE']
-
- assert(p['X-MAN-FAVOURITE'] == 'Wolverine')
- assert(p['X-FILES-FAVOURITE'] == 'Mulder')
- assert(p['X-FILES-FAVOURITE'] != 'Scully')
-
- print p.value()
- p.value("mailto:Bob@bob.com")
- print p.value()
-
-
- print p.as_ical_string()
- del p['ROLE']
- del p['X-MAN-FAVOURITE']
-
- print p.as_ical_string()
-
-
- try:
- p = Property()
- except Property.ConstructorFailedError:
- pass
- else:
- assert(0)
-
- # X Property
- p = Property("X-COMMENT")
-
- p.value("This is a sentence, with punctuation; indeed: it is")
- print p
-
- p.value("This is not approved by the Ministry of Silly Walks")
- print p
-
-
- assert(test_enum('METHOD','PUBLISH'))
- assert(not test_enum('METHOD','FOO'))
-
- assert(test_enum('ACTION','AUDIO'))
- assert(not test_enum('ACTION','OPAQUE'))
-
-def test_time():
- "Test routine"
-
- print"-------------------Test Time --------------------------------"
-
- t = Time("19970325T123010Z",'DTSTART')
-
- assert(t.year() == 1997)
- assert(t.month() == 3)
- assert(t.day() == 25)
- assert(t.hour() == 12)
- assert(t.minute() == 30)
- assert(t.second() == 10)
- assert(t.is_utc())
- assert(not t.is_date())
-
- print t
-
- t.timezone("America/Los_Angeles")
- print str(t)
- print t.timezone()
- #assert(str(t)=='DTSTART;TZID=America/Los_Angeles:19970325T123010')
- assert(str(t)=='DTSTART;TZID=/softwarestudio.org/Olson_20010626_2/America/Los_Angeles:19970325T043010')
-
- t.second(t.second()+80)
-
- t.timezone("UTC")
- assert(t.minute() == 31)
- assert(t.second() == 30)
-
- d = Duration(3600,"DURATION")
- t2 = t + d
-
- print t2
- assert(t2.hour() == 13)
-
- t2 = t - d
-
- print t2
- assert(isinstance(t2,Time))
- assert(t2.hour() == 11)
-
- # test int args
- t = Time(2)
- print t
-
- # test float args
- t = Time(2.5)
- print t
-
-def test_period():
-
- print"-------------------Test Period--------------------------------"
-
- p = Period("19970101T180000Z/19970101T233000Z")
-
- print p
-
- assert(str(p) == 'FREEBUSY:19970101T180000Z/19970101T233000Z')
-
- print p.start()
- assert(str(p.start()) == 'DTSTART:19970101T180000Z')
-
- print p.end()
- assert(str(p.end()) == 'DTEND:19970101T233000Z')
-
- print p.duration()
- assert(str(p.duration()) == 'DURATION:PT5H30M')
- p = None
-
- p = Period("19970101T180000Z/PT5H30M")
- print p
-
- print p.start()
- assert(str(p.start()) == 'DTSTART:19970101T180000Z')
-
- print p.end()
- assert(str(p.end()) == 'DTEND:19970101T233000Z')
-
- print p.duration()
- assert(str(p.duration()) == 'DURATION:PT5H30M')
-
-
-def test_duration():
-
- print "-------------- Test Duration ----------------"
-
- # Ical string
-
- d = Duration("P3DT4H25M")
-
- print str(d)
-
- assert(str(d) == "DURATION:P3DT4H25M")
-
- print d.seconds()
-
- assert(d.seconds() == 275100)
-
- # seconds
-
- d = Duration(-275100)
-
- print str(d)
-
- assert(str(d) == "DURATION:-P3DT4H25M")
-
- print d.seconds()
-
- assert(d.seconds() == -275100)
-
- #error
-
- try:
- d = Duration("P10WT7M")
- print str(d)
- assert(0)
- except: pass
-
- try:
- d = Duration("Pgiberish")
- print str(d)
- assert(0)
- except:
- pass
-
-
-
-def test_attach():
-
- file = open('littlefile.txt')
- attachProp = Attach(file)
- file.close()
- attachProp.fmttype('text/ascii')
- print "\n" + attachProp.name()
- print attachProp.value_type()
- print attachProp.fmttype()
- attachProp['fmttype']=None
- print "Calling value()"
- print attachProp.value()
- print "Calling asIcalString()"
- print attachProp.as_ical_string()
-
-
-def test_component():
-
- print "------------------- Test Component ----------------------"
-
-
- c = NewComponent(comp_str);
-
- props = c.properties()
-
- for p in props:
- print p.as_ical_string()
-
- inner = c.components()[0]
-
- print inner
- print type(inner)
-
-
- props = inner.properties()
-
- for p in props:
- print p.as_ical_string()
-
- dtstart = inner.properties('DTSTART')[0]
-
- print dtstart
-
- print "\n Orig hour: ", dtstart.hour()
- assert(dtstart.hour() == 12)
-
- dtstart.hour(dtstart.hour() + 5)
-
- print "\n New hour: ", dtstart.hour()
- assert(dtstart.hour() == 17)
-
- attendee = inner.properties('ATTENDEE')[0]
-
- print attendee
-
- t = Time("20011111T123030")
- t.name('DTEND')
-
- inner.add_property(t)
-
-
- print c
-
- dtstart1 = inner.properties('DTSTART')[0]
- dtstart2 = inner.properties('DTSTART')[0]
- dtstart3 = inner.property('DTSTART')
-
- assert(dtstart1 is dtstart2)
- assert(dtstart1 == dtstart2)
-
- assert(dtstart1 is dtstart3)
- assert(dtstart1 == dtstart3)
-
-
- p = Property(type="SUMMARY");
- p.value("This is a summary")
-
- inner.properties().append(p)
-
- print inner.as_ical_string()
-
- p = inner.properties("SUMMARY")[0]
- assert(p!=None);
- print str(p)
- assert(str(p) == "SUMMARY:This is a summary")
-
- inner.properties()[:] = [p]
-
- print inner.as_ical_string()
-
- # test sequence
- event = Event()
-
- try:
- event.sequence("foo")
- except TypeError:
- pass
-
- event.sequence(-1)
- print event.sequence()
-
- event.sequence(1)
- event.sequence(88)
- print event.sequence()
-
-def test_event():
- print "------------ Event Class ----------------------"
-
- event = Event()
-
- event.method('REQUEST')
- event.version('2.0')
-
- event.created("20010313T123000Z")
- print "created =", event.created()
- assert (event.created() == Time("20010313T123000Z"))
-
- event.organizer("MAILTO:j_doe@nowhere.com")
- org = event.organizer()
- print org.cn()
- org.cn('Jane Doe')
- assert (isinstance(org, Organizer))
- print "organizer =", event.organizer()
- assert (event.organizer().value() == "MAILTO:j_doe@nowhere.com")
-
- event.dtstart("20010401T183000Z")
- print "dtstart =", event.dtstart()
- assert (event.dtstart()== Time("20010401T183000Z"))
-
- dtend = Time('20010401T190000Z', 'DTEND')
- event.dtend(dtend)
- assert (event.dtend() ==dtend )
- assert (event.dtend() == Time('20010401T190000Z'))
-
- att = Attendee()
- att.value('jsmith@nothere.com')
- event.attendees(('ef_hutton@listenup.com', att))
-
- event.x_properties('X-TEST',('foo', 'bar'))
- event.x_properties('X-TEST2',('foo, biz', 'bar, biz'))
-
- inner = event.components()[0]
- for e in inner.properties('X-TEST'):
- print " ", e.as_ical_string()
-
- assert(len(event.x_properties('X-TEST'))==2)
-
- event.description("A short description. Longer ones break things. Really. What does it break. The code is supposed to handle realy long lines, longer, in fact, than any sane person would create except by writting a random text generator or by excerpting text from a less sane person. Actually, it did \"break\" and I had to remove an \n assert to fix it.")
- event.status('TeNtAtIvE')
-
- print event.as_ical_string()
-
-
-def test_derivedprop():
-
- print "------------ Derived Properties -----------------"
-
- p = RDate("20011111T123030")
-
- print str(p)
-
-
- p = RDate("19970101T120000/19970101T123000")
-
- print str(p)
-
- try:
- p = RDate("P3DT4H25M")
- print str(p)
- assert(0)
- except: pass
-
-
- p = Trigger("P3DT4H25M")
-
- print str(p)
-
- p = Trigger("20011111T123030")
-
- print str(p)
-
- try:
- p = Trigger("19970101T120000/19970101T123000")
- print str(p)
- assert(0)
- except: pass
-
-def test_gauge():
- print "------------ Gauge -----------------"
- event = Event()
-
- event.method('REQUEST')
- event.version('2.0')
- event.created("20010313T123000Z")
- event.organizer("MAILTO:j_doe@nowhere.com")
- org = event.organizer()
- org.cn('Jane Doe')
- event.dtstart("20010401T183000Z")
- dtend = Time('20010401T190000Z', 'DTEND')
- event.dtend(dtend)
- event.description("A short description.")
- event.status('TeNtAtIvE')
-
- print event.as_ical_string()
-
- gauge = Gauge(sql="SELECT * FROM VEVENT WHERE DTSTART > '20010401T180000Z'")
-
- assert(gauge.compare(event) == 1)
-
- gauge = Gauge(sql="SELECT * FROM VEVENT WHERE DTSTART > '20010401T190000Z'")
-
- assert(gauge.compare(event) == 0)
-
-def do_test_store(storeobj=None, *args):
- assert(storeobj != None)
- store = storeobj(*args)
- assert(store != None)
-
- print ">------------ ",
- print store.__class__,
- print "Store -----------------"
-
-
- # create fileset
-
- event = Event()
-
- event.method('REQUEST')
- event.version('2.0')
- event.created("20010313T123000Z")
- event.organizer("MAILTO:j_doe@nowhere.com")
- event.dtstart("20010401T183000Z")
- event.duration('PT3H')
-
- event.description("A short description.")
-
- # for i = 1 to 10
- # copy event
- # munge uid and increment month
- for i in range(1,11):
- newevent = event.clone()
- newevent.uid("%d@localhost" % (i,))
- newevent.dtstart().month( newevent.dtstart().month() + i )
-
- #print ne
- store.add_component(newevent)
-
- # commit
- store.commit()
- assert(store.count_components("VCALENDAR") == 10)
- # free
- del(store)
-
- # open again
- store = storeobj(*args)
- # assert count of components = 10
- assert(store.count_components("VCALENDAR") == 10)
-
- # print them out
- # fetch by uid
- n7 = store.fetch("7@localhost")
- print n7
- # fetch by match
-
- n7m = store.fetchMatch(n7)
- assert(str(n7) == str(n7m))
-
- # modify in memory
- n7.uid("42@localhost")
- del(store)
- del(n7)
-
- store = storeobj(*args)
- assert(store.fetch("42@localhost") == None)
- n7 = store.fetch("7@localhost")
- n7.uid("42@localhost")
- store.mark()
- store.commit()
- del(store)
- store = storeobj(*args)
- assert(store.fetch("7@localhost") == None)
-
- # fetch by gauge
-
- gauge = Gauge(sql="SELECT * FROM VEVENT WHERE DTSTART > '20010601T000000Z' AND DTSTART < '20010901T000000Z'")
-
- store.select(gauge)
-
- count = 0
-
- c = store.first_component()
- while c != None:
- print c.uid()
- print c.dtstart()
- print
- count = count + 1
- c = store.next_component()
-
- store.clearSelect()
-
- assert(count == 3)
-
- # remove all of them
- c = store.first_component()
- while c != None:
- print c.uid()
- store.remove_component(c)
- c = store.first_component()
-
- assert(store.count_components("VCALENDAR") == 0)
- store.commit()
- assert(store.count_components("VCALENDAR") == 0)
- # print them out
- # assert count of components = 0
-
-
-def test_store():
- print "------------ Store -----------------"
- do_test_store(FileStore,"filesetout.ics")
-
-def run_tests():
- test_property()
-
- test_time()
-
- test_period()
-
- test_component()
-
- test_duration()
-
- test_derivedprop()
-
- test_event()
-
- #test_attach()
-
- test_gauge()
-
- test_store()
-
-
-
-
-if __name__ == "__main__":
- run_tests()
-