2
from zope.interface import Interface, Attribute
5
"""A dummy interface base class"""
8
"""A dummy attribute implementation"""
9
def __init__(self, doc):
14
class IComponent(Interface):
16
Component is the base object for calendar, Event and the other
17
components defined in RFC 2445.
19
A component is like a dictionary with extra methods and attributes.
24
def __setitem__(name, value):
27
name - case insensitive name
28
value - value of the property to set. This can be either a single
31
Some iCalendar properties are set INLINE; these properties
32
have multiple values on one property line in the iCalendar
33
representation. The list can be supplied as a comma separated
34
string to __setitem__. If special iCalendar characters exist in
35
an entry, such as the colon (:) and (,), that comma-separated
36
entry needs to be quoted with double quotes. For example:
40
See also set_inline() for an easier way to deal with this case.
43
def set_inline(name, values, encode=1):
44
"""Set list of INLINE values for property.
46
Converts a list of values into valid iCalendar comma seperated
47
string and sets value to that.
49
name - case insensitive name of property
50
values - list of values to set
51
encode - if True, encode Python values as iCalendar types first.
55
"""Add a property. Can be called multiple times to set a list.
57
name - case insensitive name
58
value - value of property to set or add to list for this property.
61
def add_component(component):
62
"""Add a nested subcomponent to this component.
65
# static method, can be called on class directly
66
def from_string(st, multiple=False):
67
"""Populates the component recursively from a iCalendar string.
69
Reads the iCalendar string and constructs components and
70
subcomponents out of it.
74
def __getitem__(name):
77
name - case insensitive name
79
Returns an iCalendar property object such as vText.
82
def decoded(name, default=_marker):
83
"""Get a property as a python object.
85
name - case insensitive name
86
default - optional argument. If supplied, will use this if
87
name cannot be found. If not supplied, decoded will raise a
88
KeyError if name cannot be found.
90
Returns python object (such as unicode string, datetime, etc).
93
def get_inline(name, decode=1):
94
"""Get list of INLINE values from property.
96
name - case insensitive name
97
decode - decode to Python objects.
99
Returns list of python objects.
103
"""Render the component in the RFC 2445 (iCalendar) format.
105
Returns a string in RFC 2445 format.
108
subcomponents = Attribute("""
109
A list of all subcomponents of this component,
110
added using add_component()""")
113
Name of this component (VEVENT, etc)
117
"""Recursively traverses component and subcomponents.
119
name - optional, if given, only return components with that name
121
Returns sequence of components.
124
def property_items():
125
"""Return properties as (name, value) tuples.
127
Returns all properties in this comopnent and subcomponents as
131
class IEvent(IComponent):
132
"""A component which conforms to an iCalendar VEVENT.
135
class ITodo(IComponent):
136
"""A component which conforms to an iCalendar VTODO.
139
class IJournal(IComponent):
140
"""A component which conforms to an iCalendar VJOURNAL.
143
class IFreeBusy(IComponent):
144
"""A component which conforms to an iCalendar VFREEBUSY.
147
class ITimezone(IComponent):
148
"""A component which conforms to an iCalendar VTIMEZONE.
151
class IAlarm(IComponent):
152
"""A component which conforms to an iCalendar VALARM.
155
class ICalendar(IComponent):
156
"""A component which conforms to an iCalendar VCALENDAR.
159
class IPropertyValue(Interface):
160
"""An iCalendar property value.
161
iCalendar properties have strongly typed values.
163
This invariance should always be true:
165
assert x == vDataType.from_ical(vDataType(x).ical())
169
"""Render property as string, as defined in iCalendar RFC 2445.
172
# this is a static method
174
"""Parse property from iCalendar RFC 2445 text.
179
class IBinary(IPropertyValue):
180
"""Binary property values are base 64 encoded
183
class IBoolean(IPropertyValue):
186
Also behaves like a python int.
189
class ICalAddress(IPropertyValue):
192
Also behaves like a python str.
195
class IDateTime(IPropertyValue):
196
"""Render and generates iCalendar datetime format.
198
Important: if tzinfo is defined it renders itself as 'date with utc time'
199
Meaning that it has a 'Z' appended, and is in absolute time.
202
class IDate(IPropertyValue):
203
"""Render and generates iCalendar date format.
206
class IDuration(IPropertyValue):
207
"""Render and generates timedelta in iCalendar DURATION format.
210
class IFloat(IPropertyValue):
211
"""Render and generate floats in iCalendar format.
213
Also behaves like a python float.
216
class IInt(IPropertyValue):
217
"""Render and generate ints in iCalendar format.
219
Also behaves like a python int.
222
class IPeriod(IPropertyValue):
223
"""A precise period of time (datetime, datetime).
226
class IWeekDay(IPropertyValue):
227
"""Render and generate weekday abbreviation.
230
class IFrequency(IPropertyValue):
234
class IRecur(IPropertyValue):
235
"""Render and generate data based on recurrent event representation.
237
This acts like a caseless dictionary.
240
class IText(IPropertyValue):
244
class ITime(IPropertyValue):
248
class IUri(IPropertyValue):
252
class IGeo(IPropertyValue):
253
"""Geographical location.
256
class IUTCOffset(IPropertyValue):
260
class IInline(IPropertyValue):