summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorKent Sutherland <git@ksuther.com>2017-10-01 19:46:59 -0500
committerKent Sutherland <git@ksuther.com>2017-10-01 19:46:59 -0500
commit9b1d3f20be51498c971676d398f2403d8dca2194 (patch)
treecf7ab513307175365210defe81ea3347010fabf7 /src/python
parente96920a7ca445f0e6cfd72efb2f4a4f6baed1957 (diff)
parent529fdd0ea55d81dc8aaeb130de965feddf8dbbb3 (diff)
downloadlibical-git-9b1d3f20be51498c971676d398f2403d8dca2194.tar.gz
Merge branch 'master' into remove-is_utc
Diffstat (limited to 'src/python')
-rw-r--r--src/python/Attendee.py43
-rw-r--r--src/python/Collection.py37
-rw-r--r--src/python/Component.py131
-rw-r--r--src/python/DerivedProperties.py38
-rw-r--r--src/python/Duration.py41
-rw-r--r--src/python/Error.py29
-rw-r--r--src/python/Gauge.py19
-rw-r--r--src/python/Libical.py29
-rw-r--r--src/python/LibicalWrap.i2
-rw-r--r--src/python/Period.py49
-rw-r--r--src/python/Property.py93
-rw-r--r--src/python/Store.py84
-rw-r--r--src/python/Time.py71
-rw-r--r--src/python/__init__.py22
-rw-r--r--src/python/test.py114
15 files changed, 380 insertions, 422 deletions
diff --git a/src/python/Attendee.py b/src/python/Attendee.py
index 874f4b66..8f65a354 100644
--- a/src/python/Attendee.py
+++ b/src/python/Attendee.py
@@ -1,27 +1,32 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Property.py
-# CREATOR: eric
+# CREATOR: eric
#
-# DESCRIPTION:
-#
+# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
+# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
#
-# $Id: Attendee.py,v 1.1 2001-04-03 15:18:42 ebusboom Exp $
-# $Locker: $
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of either:
#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
+#
+# Or:
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+
+
+# This library 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
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
#
# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
+# The Mozilla Public License Version 2.0. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#======================================================================
@@ -41,20 +46,20 @@ class Attendee(Property):
'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
+ 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
@@ -81,12 +86,12 @@ class 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
diff --git a/src/python/Collection.py b/src/python/Collection.py
index 9d45f28f..eb5f6c92 100644
--- a/src/python/Collection.py
+++ b/src/python/Collection.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Collection.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Collection.py,v 1.3 2001-03-11 00:46:57 plewis Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from types import *
@@ -58,7 +51,7 @@ class Collection:
self._properties[beg:end] = sequence
for p in sequence:
self._component.add_property(p)
-
+
def __getitem__(self, i):
return self._properties[i]
@@ -82,13 +75,13 @@ class Collection:
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[:])
@@ -118,11 +111,11 @@ class ComponentCollection:
def __len__(self):
return len(self._components)
-
+
def __add__(self, iterable):
for i in iterable:
self.append(i)
-
+
def append(self, property):
self._components.append(property)
self._parent.add_component(property)
diff --git a/src/python/Component.py b/src/python/Component.py
index 4f640201..9fa81b03 100644
--- a/src/python/Component.py
+++ b/src/python/Component.py
@@ -1,28 +1,32 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Component.py
-# CREATOR: eric
+# CREATOR: eric
#
-# DESCRIPTION:
-#
+# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
+# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
#
-# $Id: Component.py,v 1.15 2002-10-24 13:41:17 acampi Exp $
-# $Locker: $
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of either:
#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of either:
+# Or:
+#
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import *
@@ -41,13 +45,13 @@ WrapperNULL = None
class SwigRefHash(dict):
def __getitem__(self, k):
return dict.__getitem__(self, int(k))
-
+
def __setitem__(self, k, v):
return dict.__setitem__(self, int(k), v)
-
+
def __delitem__(self, k):
dict.__delitem__(self, int(k))
-
+
def has_key(self, k):
return dict.has_key(self, int(k))
@@ -63,7 +67,7 @@ class Component(object):
icalcomponent_string_to_kind("VCALENDAR"))
_kind = icalcomponent_string_to_kind(kind)
inner = icalcomponent_new(_kind)
-
+
icalcomponent_add_component(self._ref,inner);
else:
@@ -77,7 +81,7 @@ class Component(object):
for k in self.cached_props.keys():
del self.cached_props[k]
-
+
icalcomponent_free(self._ref)
self._ref = None
@@ -86,19 +90,19 @@ class Component(object):
if(p == None or p== WrapperNULL):
return None;
- d = {}
- d['value'] = icalproperty_get_value_as_string(p)
- d['name'] = icalproperty_get_property_name(p)
+ d = {}
+ d['value'] = icalproperty_get_value_as_string(p)
+ d['name'] = icalproperty_get_property_name(p)
- propkind = icalproperty_string_to_kind(d['name'])
- kind = icalproperty_kind_to_value_kind(propkind)
- d['value_type'] = icalvalue_kind_to_string(kind)
+ 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
#~ print p, Property(ref=p).name()
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':
@@ -113,22 +117,22 @@ class Component(object):
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)
+ p = icallangbind_get_first_property(self._ref,type)
if p !=WrapperNULL:
self._prop_from_ref(p)
prop = self.cached_props[p]
return prop
- else :
+ else :
return None
- def properties(self,type='ANY'):
- """
+ def properties(self,type='ANY'):
+ """
Return a list of Property instances, each representing a
property of the type 'type.'
"""
@@ -145,10 +149,10 @@ class Component(object):
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
@@ -176,7 +180,7 @@ class Component(object):
del self.cached_props[prop.ref()]
icalcomponent_remove_property(self._ref,prop.ref())
- def components(self,type='ANY'):
+ def components(self,type='ANY'):
comps = []
kind = icalcomponent_string_to_kind(type)
@@ -184,7 +188,7 @@ class Component(object):
while c != WrapperNULL and c != None:
- if not self.cached_comps.has_key(c):
+ if not self.cached_comps.has_key(c):
self.cached_comps[c] = Component(c)
@@ -195,7 +199,7 @@ class Component(object):
return ComponentCollection(self, comps)
def inner_component(self):
-
+
inner = icalcomponent_get_inner(self._ref)
if inner == WrapperNULL and inner != None:
@@ -210,7 +214,7 @@ class Component(object):
raise ValueError("Expected a Component")
if icalcomponent_get_parent(comp._ref) != WrapperNULL:
- raise "Failed to add child component. Child already has a parent";
+ raise "Failed to add child component. Child already has a parent";
icalcomponent_add_component(self._ref,comp._ref)
@@ -234,8 +238,8 @@ class Component(object):
return icalcomponent_kind_to_string(k)
def ref(self):
- """ Return the internal reference to the libical icalproperty """
- return self._ref
+ """ 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."
@@ -256,10 +260,10 @@ def CloneComponent(c):
kindStr = icalcomponent_kind_to_string(kind)
if kindStr == 'VCALENDAR':
- inner = icalcomponent_get_inner(comp)
- kind = icalcomponent_isa(inner)
- kindStr = icalcomponent_kind_to_string(kind)
-
+ inner = icalcomponent_get_inner(comp)
+ kind = icalcomponent_isa(inner)
+ kindStr = icalcomponent_kind_to_string(kind)
+
if kindStr == 'VEVENT':
newComp = Event(comp)
elif kindStr == 'VTODO':
@@ -309,15 +313,15 @@ def NewComponent(c):
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,
@@ -421,11 +425,11 @@ class GenericComponent(Component):
Usage:
created(time_obj) # Set the value using a Time object
created('19970101T123000Z') # Set using an iCalendar string
- created(982362522) # Set using seconds
+ 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)
@@ -436,7 +440,7 @@ class GenericComponent(Component):
Usage:
dtstamp(time_obj) # Set the value using a Time object
dtstamp('19970101T123000Z')# Set using an iCalendar string
- dtstamp(982362522) # Set using seconds
+ dtstamp(982362522) # Set using seconds
dtstamp() # Return an iCalendar string
"""
return self._singular_property("DTSTAMP", "DATE-TIME", v, Time)
@@ -458,7 +462,7 @@ class GenericComponent(Component):
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(982362522) # Set using seconds
last_modified() # Return an iCalendar string
"""
return self._singular_property("LAST-MODIFIED", "DATE-TIME", v, Time)
@@ -513,7 +517,7 @@ class GenericComponent(Component):
####
# 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
@@ -555,7 +559,7 @@ class GenericComponent(Component):
# 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
@@ -564,12 +568,12 @@ class GenericComponent(Component):
else: # Use existing object
new_prop = v
else: # Generic properties
- new_prop=Property(name)
+ 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))
@@ -647,9 +651,9 @@ class Event(GenericComponent):
def __init__(self,ref=None):
if ref != None:
GenericComponent.__init__(self, ref=ref)
- else:
+ else:
GenericComponent.__init__(self, kind='VEVENT')
-
+
def component_type(self):
"Returns the type of component for the object."
return "VEVENT"
@@ -671,7 +675,7 @@ class Event(GenericComponent):
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.
@@ -718,7 +722,7 @@ class Event(GenericComponent):
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)
@@ -749,7 +753,7 @@ class Todo(GenericComponent):
def __init__(self,ref=None):
if ref != None:
GenericComponent.__init__(self, ref=ref)
- else:
+ else:
GenericComponent.__init__(self, kind='VTODO')
@@ -803,7 +807,7 @@ class Journal(GenericComponent):
def __init__(self):
if ref != None:
GenericComponent.__init__(self, ref=ref)
- else:
+ else:
GenericComponent.__init__(self, kind='VJOURNAL')
def component_type(self):
@@ -816,4 +820,3 @@ class Journal(GenericComponent):
ok_values=('DRAFT', 'FINAL', 'CANCELLED')
return self._singular_property('STATUS', 'TEXT', v,
enumerated_values=ok_values)
-
diff --git a/src/python/DerivedProperties.py b/src/python/DerivedProperties.py
index 71ad640e..9aa06676 100644
--- a/src/python/DerivedProperties.py
+++ b/src/python/DerivedProperties.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: DerivedProperties.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: DerivedProperties.py,v 1.4 2001-04-03 15:18:42 ebusboom Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from Property import Property
@@ -34,7 +27,7 @@ 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")
@@ -45,17 +38,17 @@ def RDate(arg):
raise Property.ConstructorFailedError("Failed to construct RDATE from "+str(arg))
-def Trigger(arg):
- class Trigger_Time(Time):
+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
+ except Property.ConstructorFailedError, d: pass
raise Property.ConstructorFailedError("Failed to construct TRIGGER from "+str(arg))
@@ -156,4 +149,3 @@ class Attach(Property):
self['FMTTYPE']=v
else:
return self['FMTTYPE']
-
diff --git a/src/python/Duration.py b/src/python/Duration.py
index 57fe25e6..fe555149 100644
--- a/src/python/Duration.py
+++ b/src/python/Duration.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Duration.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Duration.py,v 1.1 2001-04-03 15:18:42 ebusboom Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#===============================================================
from LibicalWrap import *
@@ -30,9 +23,9 @@ 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.
-
+
"""
@@ -42,21 +35,21 @@ class Duration(Property):
Construct the duration from an iCalendar string or a number of seconds.
Duration("P3DT2H34M45S") Construct from an iCalendar string
- Duration(3660) Construct from seconds
- """
+ 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):
+ elif isinstance(arg, IntType):
self.dur = icaldurationtype_from_int(arg)
elif isinstance(arg,Duration):
self.dur = arg.dur
@@ -76,7 +69,7 @@ class Duration(Property):
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):
diff --git a/src/python/Error.py b/src/python/Error.py
index 912553d1..043dfa84 100644
--- a/src/python/Error.py
+++ b/src/python/Error.py
@@ -1,5 +1,34 @@
+#======================================================================
+# FILE: Error.py
+# CREATOR: eric
+#
+# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
+# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+#
+# This library 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.gnu.org/licenses/lgpl-2.1.txt
+#
+# Or:
+#
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+# This library 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.gnu.org/licenses/lgpl-2.1.html
+#
+# Or:
+#
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#===========================================================
+
class LibicalError(Exception):
"Libical Error"
diff --git a/src/python/Gauge.py b/src/python/Gauge.py
index d016cfea..b4736c7d 100644
--- a/src/python/Gauge.py
+++ b/src/python/Gauge.py
@@ -1,28 +1,21 @@
#!/usr/bin/env python
-# -*- Mode: python -*-
#======================================================================
# FILE: Gauge.py
# CREATOR: mtearle
#
-# DESCRIPTION:
-#
-#
-# $Id: Gauge.py,v 1.2 2002-07-08 17:56:11 acampi Exp $
-# $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
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import *
diff --git a/src/python/Libical.py b/src/python/Libical.py
index 5f4aae70..ac3ad342 100644
--- a/src/python/Libical.py
+++ b/src/python/Libical.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Libical.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Libical.py,v 1.19 2002-06-03 13:25:28 acampi Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import ICAL_PACKAGE, ICAL_VERSION
@@ -32,7 +25,7 @@ from Time import Time, UTC
from Period import Period
from Duration import Duration
from Attendee import Attendee, Organizer
-from DerivedProperties import RDate, Trigger,Recurrence_Id, Attach
+from DerivedProperties import RDate, Trigger,Recurrence_Id, Attach
from Store import Store, FileStore
from Gauge import Gauge
diff --git a/src/python/LibicalWrap.i b/src/python/LibicalWrap.i
index 94943039..2330eeff 100644
--- a/src/python/LibicalWrap.i
+++ b/src/python/LibicalWrap.i
@@ -2,7 +2,7 @@
/*======================================================================
FILE: ical.i
- (C) COPYRIGHT 1999 Eric Busboom
+ (C) COPYRIGHT 1999 Eric Busboom <eric@softwarestudio.org>
http://www.softwarestudio.org
The contents of this file are subject to the Mozilla Public License
diff --git a/src/python/Period.py b/src/python/Period.py
index fb998160..3ecc947e 100644
--- a/src/python/Period.py
+++ b/src/python/Period.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Period.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Period.py,v 1.1 2001-04-03 15:18:42 ebusboom Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#===========================================================
from LibicalWrap import *
@@ -39,13 +32,13 @@ class Period(Property):
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'])
@@ -61,7 +54,7 @@ class Period(Property):
self.pt = icalperiodtype_null_period()
Property.__init__(self,type=name)
-
+
icalerror_restore("MALFORMEDDATA",e1)
icalerror_restore("BADARG",e2)
@@ -69,13 +62,13 @@ class Period(Property):
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):
+ def _end_is_duration(self):
dur = self.pt.duration
if not icaldurationtype_is_null_duration(dur):
return 1
@@ -115,8 +108,8 @@ class Period(Property):
self.pt.start = t.tt
self._update_value()
-
-
+
+
return Time(self.pt.start.as_timet(),
"DTSTART")
@@ -130,7 +123,7 @@ class Period(Property):
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):
@@ -144,7 +137,7 @@ class Period(Property):
self.pt.duration = icaldurationtype_from_int(dur)
else:
self.pt.end = t.tt
-
+
self._update_value()
if(self._end_is_time()):
@@ -173,7 +166,7 @@ class Period(Property):
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):
@@ -188,7 +181,7 @@ class Period(Property):
self.pt.end = icaltimetype.from_timet(end)
else:
self.pt.duration = d.dur
-
+
if(self._end_is_time()):
start = self.pt.start.as_timet()
end = self.pt.end.as_timet()
diff --git a/src/python/Property.py b/src/python/Property.py
index a53585ea..0809c211 100644
--- a/src/python/Property.py
+++ b/src/python/Property.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Property.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Property.py,v 1.13 2002-10-24 13:44:30 acampi Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import *
@@ -31,7 +24,7 @@ import base64
from string import index, upper, split
from types import StringType
-#def icalerror_supress(arg):
+#def icalerror_supress(arg):
# pass
#def icalerror_restore(a,b):
@@ -48,7 +41,7 @@ def test_enum(prop,enum):
if e != 0:
return 1
-
+
return None
@@ -68,7 +61,7 @@ class Property(object):
class UpdateFailedError(Exception):
"Failed to update the value of a property"
-
+
def __init__(self, type = None, ref = None):
@@ -77,19 +70,19 @@ class Property(object):
#~ 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:
+ 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: %s (%s)"%(type, ref))
-
+
self._deleted = 0;
# Initialize all of the required keys
@@ -102,9 +95,9 @@ class Property(object):
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_property_name(self._ref)
@@ -115,7 +108,7 @@ class Property(object):
if not self._deleted and self._ref and \
icalproperty_get_parent(self._ref) == 'NULL':
-
+
icalproperty_free(self._ref)
self._ref = v
@@ -127,9 +120,9 @@ class Property(object):
""" Return the RFC2445 representation of the value """
if(v != None):
-
+
if kind != None:
- # Get the default kind of value for this property
+ # 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())))
@@ -165,19 +158,19 @@ class Property(object):
def parameters(self):
"""
- Return a list of parameters
+ Return a list of parameters
"""
- params = []
+ params = []
+
+ p = icallangbind_get_first_parameter(self._ref)
- 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)
+ while p != None:
+ kv = split(icalparameter_as_ical_string(p),'=',2)
+ params.append(kv[0])
+ p = icallangbind_get_next_parameter(self._ref)
- return params
+ return params
def as_ical_string(self):
"Return the property in iCalendar text format."
@@ -187,7 +180,7 @@ class Property(object):
""" Return property values by name """
key = upper(key)
str = icalproperty_get_parameter_as_string(self._ref,key)
-
+
if(str == 'NULL'): return None
return str
@@ -204,8 +197,8 @@ class Property(object):
""" Remove Property Values by Name """
key = upper(key)
- if self.__getitem__(key):
- icalproperty_remove_parameter_by_name(self._ref,key)
+ if self.__getitem__(key):
+ icalproperty_remove_parameter_by_name(self._ref,key)
def __str__(self):
@@ -219,19 +212,19 @@ class Property(object):
return cmp(s_str,o_str)
-class RecurrenceSet:
+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.
+ 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.
+ 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
@@ -245,9 +238,9 @@ class RecurrenceSet:
"""
pass
- def exclude(self, **params):
- """
- Exclude date or rule to the set.
+ 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
@@ -259,11 +252,9 @@ class RecurrenceSet:
"""
pass
-
+
def occurrences(self, count=None):
"""
Return 'count' occurrences as a tuple of Time instances.
"""
pass
-
-
diff --git a/src/python/Store.py b/src/python/Store.py
index 9ecea991..dd6ff696 100644
--- a/src/python/Store.py
+++ b/src/python/Store.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Store.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Store.py,v 1.4 2002-07-08 17:56:11 acampi Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import *
@@ -31,58 +24,58 @@ from Component import Component, CloneComponent
from Gauge import Gauge
class Store:
- """
- Base class for several component storage methods
+ """
+ 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):
+
+ 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
@@ -106,13 +99,13 @@ class FileStore(Store):
def mark(self):
icalfileset_mark(self._ref)
- def commit(self):
+ 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):
@@ -122,18 +115,18 @@ class FileStore(Store):
error = icalfileset_remove_component(self._ref,comp.ref())
def count_components(self, kind):
- _kind = icalcomponent_string_to_kind(kind)
+ _kind = icalcomponent_string_to_kind(kind)
- return icalfileset_count_components(self._ref, _kind)
+ return icalfileset_count_components(self._ref, _kind)
def select(self, gauge):
- error = icalfileset_select(self._ref, gauge.ref())
+ error = icalfileset_select(self._ref, gauge.ref())
def clearSelect(self):
- icalfileset_clear(self._ref)
+ icalfileset_clear(self._ref)
def fetch(self, uid):
- comp_ref = icalfileset_fetch(self._ref, uid)
+ comp_ref = icalfileset_fetch(self._ref, uid)
if comp_ref == None:
return None
@@ -143,7 +136,7 @@ class FileStore(Store):
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:
@@ -152,7 +145,7 @@ class FileStore(Store):
return CloneComponent(comp_ref)
def modify(self, oldc, newc):
- pass
+ pass
def current_component(self):
comp_ref = icalfileset_get_current_component(self._ref)
@@ -171,11 +164,10 @@ class FileStore(Store):
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/src/python/Time.py b/src/python/Time.py
index 4fdcb1cf..bc449e56 100644
--- a/src/python/Time.py
+++ b/src/python/Time.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: Time.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: Time.py,v 1.3 2002-07-12 08:02:46 acampi Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from LibicalWrap import *
@@ -35,13 +28,13 @@ UTC = icaltimezone_get_utc_timezone()
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
+ """
+ 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")
@@ -55,12 +48,12 @@ class Time(Property):
# Create from an iCal string
self.tt = icaltime_from_string(arg)
elif isinstance(arg, IntType) or \
- isinstance(arg, FloatType):
+ 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())
+ 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
@@ -107,27 +100,27 @@ class Time(Property):
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):
+ origtz = icaltime_get_tzid(self.tt)
+
+ if (v != None):
assert(isinstance(v,StringType) )
- if (v == "UTC"):
+ if (v == "UTC"):
tz = icaltimezone_get_utc_timezone()
- del self['TZID']
+ del self['TZID']
else:
- tz = icaltimezone_get_builtin_timezone(v)
+ tz = icaltimezone_get_builtin_timezone(v)
if not origtz:
- self.tt = icaltime_set_timezone(self.tt, tz)
+ self.tt = icaltime_set_timezone(self.tt, tz)
else:
- self.tt = icaltime_convert_to_zone(self.tt,tz)
+ self.tt = icaltime_convert_to_zone(self.tt,tz)
- if (icaltime_get_tzid(self.tt) != "UTC"):
- self['TZID'] = icaltime_get_tzid(self.tt)
+ if (icaltime_get_tzid(self.tt) != "UTC"):
+ self['TZID'] = icaltime_get_tzid(self.tt)
self._update_value()
- return icaltime_get_tzid(self.tt)
+ return icaltime_get_tzid(self.tt)
def normalize(self):
self.tt = icaltime_normalize(self.tt)
@@ -191,7 +184,7 @@ class Time(Property):
def __add__(self,o):
- other = Duration(o,"DURATION")
+ other = Duration(o,"DURATION")
if not other.valid():
return Duration(0,"DURATION")
@@ -205,11 +198,11 @@ class Time(Property):
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() - o.utc_seconds()
diff --git a/src/python/__init__.py b/src/python/__init__.py
index bbae718c..794b8f91 100644
--- a/src/python/__init__.py
+++ b/src/python/__init__.py
@@ -1,25 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: __init__.py
# CREATOR: glenn
#
-# DESCRIPTION:
-#
-#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
from Libical import *
diff --git a/src/python/test.py b/src/python/test.py
index 1d82062a..e523d2ba 100644
--- a/src/python/test.py
+++ b/src/python/test.py
@@ -1,28 +1,21 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/usr/bin/env python
#======================================================================
# FILE: test.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id: test.py,v 1.24 2002-10-24 13:44:31 acampi Exp $
-# $Locker: $
+# CREATOR: eric
#
# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
+# (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:
+# This library 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
+# The LGPL as published by the Free Software Foundation, version
+# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt
#
-# Or:
+# Or:
#
-# The Mozilla Public License Version 1.0. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
+# The Mozilla Public License Version 2.0. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
#======================================================================
import LibicalWrap
@@ -39,7 +32,7 @@ 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
+COMMENT: When in the course of writting comments and nonsense text\, it
becomes necessary to insert a newline
DTSTART:19972512T120000
DTSTART:19970101T120000Z
@@ -68,10 +61,10 @@ def test_property():
print
print "Parameters:"
for param in p.parameters():
- print " ", param, " = ", p[param]
+ print " ", param, " = ", p[param]
print
print p['ROLE']
-
+
p['ROLE'] = 'INDIVIDUAL'
print p['ROLE']
@@ -99,7 +92,7 @@ def test_property():
print p.as_ical_string()
del p['ROLE']
del p['X-MAN-FAVOURITE']
-
+
print p.as_ical_string()
@@ -132,7 +125,7 @@ def test_time():
print"-------------------Test Time --------------------------------"
t = Time("19970325T123010Z",'DTSTART')
-
+
assert(t.year == 1997)
assert(t.month == 3)
assert(t.day == 25)
@@ -141,7 +134,7 @@ def test_time():
assert(t.second == 10)
assert(t.is_utc())
assert(not t.is_date())
-
+
print t
t.timezone("America/Los_Angeles")
@@ -172,19 +165,19 @@ def test_time():
# test int args
t = Time(2)
print t
-
+
# test float args
t = Time(2.5)
print t
-def test_period():
+def test_period():
print"-------------------Test Period--------------------------------"
p = Period("19970101T180000Z/19970101T233000Z")
print p
-
+
assert(str(p) == 'FREEBUSY:19970101T180000Z/19970101T233000Z')
print p.start()
@@ -229,7 +222,7 @@ def test_duration():
# seconds
d = Duration(-275100)
-
+
print str(d)
assert(str(d) == "DURATION:-P3DT4H25M")
@@ -279,10 +272,10 @@ def test_component():
c = NewComponent(comp_str);
props = c.properties()
-
- for p in props:
+
+ for p in props:
print p.as_ical_string()
-
+
inner = c.components()[0]
print inner
@@ -290,14 +283,14 @@ def test_component():
props = inner.properties()
-
- for p in props:
+
+ 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)
@@ -307,7 +300,7 @@ def test_component():
assert(dtstart.hour == 17)
attendee = inner.properties('ATTENDEE')[0]
-
+
print attendee
t = Time("20011111T123030")
@@ -345,7 +338,7 @@ def test_component():
print inner.as_ical_string()
- # test sequence
+ # test sequence
event = Event()
try:
@@ -359,7 +352,7 @@ def test_component():
event.sequence(1)
event.sequence(88)
print event.sequence()
-
+
def test_event():
print "------------ Event Class ----------------------"
@@ -388,11 +381,11 @@ def test_event():
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'))
@@ -404,14 +397,14 @@ def test_event():
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)
@@ -427,7 +420,7 @@ def test_derivedprop():
assert(0)
except: pass
-
+
p = Trigger("P3DT4H25M")
print str(p)
@@ -457,7 +450,7 @@ def test_gauge():
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'")
@@ -495,12 +488,12 @@ def do_test_store(storeobj=None, *args):
# 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
+ newevent = event.clone()
+ newevent.uid("%d@localhost" % (i,))
+ newevent.dtstart().month = newevent.dtstart().month + i
- #print ne
- store.add_component(newevent)
+ #print ne
+ store.add_component(newevent)
# commit
store.commit()
@@ -547,11 +540,11 @@ def do_test_store(storeobj=None, *args):
c = store.first_component()
while c != None:
- print c.uid()
- print c.dtstart()
- print
- count = count + 1
- c = store.next_component()
+ print c.uid()
+ print c.dtstart()
+ print
+ count = count + 1
+ c = store.next_component()
store.clearSelect()
@@ -560,9 +553,9 @@ def do_test_store(storeobj=None, *args):
# remove all of them
c = store.first_component()
while c != None:
- print c.uid()
- store.remove_component(c)
- c = store.first_component()
+ print c.uid()
+ store.remove_component(c)
+ c = store.first_component()
assert(store.count_components("VCALENDAR") == 0)
store.commit()
@@ -595,7 +588,7 @@ def run_tests():
#test_attach()
test_gauge()
-
+
test_store()
@@ -603,4 +596,3 @@ def run_tests():
if __name__ == "__main__":
run_tests()
-