API Reference

icalendar.cal

Calendar is a dictionary like Python object that can render itself as VCAL files according to rfc2445.

These are the defined components.

class icalendar.cal.Calendar(*args, **kwargs)[source]

This is the base object for an iCalendar file.

class icalendar.cal.Component(*args, **kwargs)[source]

Component is the base object for calendar, Event and the other components defined in RFC 2445. normally you will not use this class directy, but rather one of the subclasses.

add(name, value, parameters=None, encode=1)[source]

Add a property.

Parameters:
  • name (string) – Name of the property.
  • value (Python native type or icalendar property type.) – Value of the property. Either of a basic Python type of any of the icalendar’s own property types.
  • parameters (Dictionary) – Property parameter dictionary for the value. Only available, if encode is set to True.
  • encode (Boolean) – True, if the value should be encoded to one of icalendar’s own property types (Fallback is “vText”) or False, if not.
Returns:

None

add_component(component)[source]

Add a subcomponent to this component.

content_line(name, value, sorted=True)[source]

Returns property as content line.

content_lines(sorted=True)[source]

Converts the Component and subcomponents into content lines.

decoded(name, default=[])[source]

Returns decoded value of property.

classmethod from_ical(st, multiple=False)[source]

Populates the component recursively from a string.

get_inline(name, decode=1)[source]

Returns a list of values (split on comma).

property_items(recursive=True, sorted=True)[source]

Returns properties in this component and subcomponents as: [(name, value), ...]

set_inline(name, values, encode=1)[source]

Converts a list of values into comma seperated string and sets value to that.

to_ical(sorted=True)[source]
Parameters:sorted – Whether parameters and properties should be lexicographically sorted.
walk(name=None)[source]

Recursively traverses component and subcomponents. Returns sequence of same. If name is passed, only components with name will be returned.

class icalendar.cal.ComponentFactory(*args, **kwargs)[source]

All components defined in rfc 2445 are registered in this factory class. To get a component you can use it like this.

icalendar.prop

This module contains the parser/generators (or coders/encoders if you prefer) for the classes/datatypes that are used in iCalendar:

4.2 Defined property parameters are:

ALTREP, CN, CUTYPE, DELEGATED-FROM, DELEGATED-TO, DIR, ENCODING, FMTTYPE, FBTYPE, LANGUAGE, MEMBER, PARTSTAT, RANGE, RELATED, RELTYPE, ROLE, RSVP, SENT-BY, TZID, VALUE

4.3 Defined value data types are:

BINARY, BOOLEAN, CAL-ADDRESS, DATE, DATE-TIME, DURATION, FLOAT, INTEGER, PERIOD, RECUR, TEXT, TIME, URI, UTC-OFFSET

iCalendar properties has values. The values are strongly typed. This module defines these types, calling val.to_ical() on them, Will render them as defined in rfc2445.

If you pass any of these classes a Python primitive, you will have an object that can render itself as iCalendar formatted date.

Property Value Data Types starts with a ‘v’. they all have an to_ical() and from_ical() method. The to_ical() method generates a text string in the iCalendar format. The from_ical() method can parse this format and return a primitive Python datatype. So it should allways be true that:

x == vDataType.from_ical(VDataType(x).to_ical())

These types are mainly used for parsing and file generation. But you can set them directly.

class icalendar.prop.FixedOffset(offset, name)[source]

Fixed offset in minutes east from UTC.

class icalendar.prop.LocalTimezone[source]

Timezone of the machine where the code is running.

class icalendar.prop.TypesFactory(*args, **kwargs)[source]

All Value types defined in rfc 2445 are registered in this factory class.

The value and parameter names don’t overlap. So one factory is enough for both kinds.

for_property(name)[source]

Returns a the default type for a property or parameter

from_ical(name, value)[source]

Decodes a named property or parameter value from an icalendar encoded string to a primitive python type.

to_ical(name, value)[source]

Encodes a named value from a primitive python type to an icalendar encoded string.

class icalendar.prop.vBinary(obj)[source]

Binary property values are base 64 encoded.

class icalendar.prop.vBoolean[source]

Returns specific string according to state.

class icalendar.prop.vCalAddress[source]

This just returns an unquoted string.

class icalendar.prop.vDDDLists(dt_list)[source]

A list of vDDDTypes values.

class icalendar.prop.vDDDTypes(dt)[source]

A combined Datetime, Date or Duration parser/generator. Their format cannot be confused, and often values can be of either types. So this is practical.

class icalendar.prop.vDate(dt)[source]

Render and generates iCalendar date format.

class icalendar.prop.vDatetime(dt)[source]

Render and generates icalendar datetime format.

vDatetime is timezone aware and uses the pytz library, an implementation of the Olson database in Python. When a vDatetime object is created from an ical string, you can pass a valid pytz timezone identifier. When a vDatetime object is created from a python datetime object, it uses the tzinfo component, if present. Otherwise an timezone-naive object is created. Be aware that there are certain limitations with timezone naive DATE-TIME components in the icalendar standard.

class icalendar.prop.vDuration(td)[source]

Subclass of timedelta that renders itself in the iCalendar DURATION format.

class icalendar.prop.vFloat[source]

Just a float.

class icalendar.prop.vFrequency[source]

A simple class that catches illegal values.

class icalendar.prop.vGeo(geo)[source]

A special type that is only indirectly defined in the rfc.

class icalendar.prop.vInline[source]

This is an especially dumb class that just holds raw unparsed text and has parameters. Conversion of inline values are handled by the Component class, so no further processing is needed.

class icalendar.prop.vInt[source]

Just an int.

class icalendar.prop.vPeriod(per)[source]

A precise period of time.

class icalendar.prop.vRecur(*args, **kwargs)[source]

Recurrence definition.

class icalendar.prop.vText[source]

Simple text.

class icalendar.prop.vTime(*args)[source]

Render and generates iCalendar time format.

class icalendar.prop.vUTCOffset(td)[source]

Renders itself as a utc offset.

class icalendar.prop.vUri[source]

Uniform resource identifier is basically just an unquoted string.

class icalendar.prop.vWeekday[source]

This returns an unquoted weekday abbrevation.