API description

Calendar

class ics.icalendar.Calendar(imports: str | Container | None = None, events: Iterable[Event] | None = None, todos: Iterable[Todo] | None = None, creator: str = None, **kwargs)[source]

Represents a unique RFC 5545 iCalendar.

events

a list of Event contained in the Calendar

Type:

List[ics.event.Event]

todos

a list of Todo contained in the Calendar

Type:

List[ics.todo.Todo]

timeline

a Timeline instance for iterating this Calendar in chronological order

__init__(imports: str | Container | None = None, events: Iterable[Event] | None = None, todos: Iterable[Todo] | None = None, creator: str = None, **kwargs)[source]

Initializes a new Calendar.

Parameters:
  • imports (str) – data to be imported into the Calendar,

  • events (Iterable[Event]) – Event to be added to the calendar

  • todos (Iterable[Todo]) – Todo to be added to the calendar

  • creator (string) – uid of the creator program.

__iter__() Iterator[str][source]

Returns: iterable: an iterable version of __str__, line per line (with line-endings).

Example

Can be used to write calendar to a file:

>>> c = Calendar(); c.events.append(Event(summary="My cool event"))
>>> open('my.ics', 'w').writelines(c)
__str__() str[source]

Return str(self).

classmethod parse_multiple(string)[source]

” Parses an input string that may contain multiple calendars and returns a list of ics.event.Calendar

Event

class ics.event.Event(summary: str = None, begin: Tuple | Dict | datetime | date = None, end: Tuple | Dict | datetime | date = None, duration: Tuple | Dict | timedelta = None, *args, **kwargs)[source]

A calendar event.

Can be full-day or between two instants. Can be defined by a beginning instant and a duration or end instant.

Unsupported event attributes can be found in event.extra, a ics.parse.Container. You may add some by appending a ics.parse.ContentLine to .extra

__init__(summary: str = None, begin: Tuple | Dict | datetime | date = None, end: Tuple | Dict | datetime | date = None, duration: Tuple | Dict | timedelta = None, *args, **kwargs)[source]

Initializes a new ics.event.Event.

Raises:

ValueError – if timespan and any of begin, end or duration are specified at the same time, or if validation of the timespan fails (see ics.timespan.Timespan.validate()).

Alarms

class ics.alarm.BaseAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None)[source]

A calendar event VALARM base class

__eq__(other)

Method generated by attrs for class BaseAlarm.

__ge__(other)

Method generated by attrs for class BaseAlarm.

__gt__(other)

Method generated by attrs for class BaseAlarm.

__init__(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None) None

Method generated by attrs for class BaseAlarm.

__le__(other)

Method generated by attrs for class BaseAlarm.

__lt__(other)

Method generated by attrs for class BaseAlarm.

__ne__(other)

Method generated by attrs for class BaseAlarm.

__repr__()

Method generated by attrs for class BaseAlarm.

__hash__ = None
abstract property action

VALARM action to be implemented by concrete classes

class ics.alarm.AudioAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, attach: ParseResult | bytes | None = None)[source]

A calendar event VALARM with AUDIO option.

__eq__(other)

Method generated by attrs for class AudioAlarm.

__ge__(other)

Method generated by attrs for class AudioAlarm.

__gt__(other)

Method generated by attrs for class AudioAlarm.

__init__(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, attach: ParseResult | bytes | None = None) None

Method generated by attrs for class AudioAlarm.

__le__(other)

Method generated by attrs for class AudioAlarm.

__lt__(other)

Method generated by attrs for class AudioAlarm.

__ne__(other)

Method generated by attrs for class AudioAlarm.

__repr__()

Method generated by attrs for class AudioAlarm.

__hash__ = None
property action

VALARM action to be implemented by concrete classes

class ics.alarm.DisplayAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, description: str = None)[source]

A calendar event VALARM with DISPLAY option.

__eq__(other)

Method generated by attrs for class DisplayAlarm.

__ge__(other)

Method generated by attrs for class DisplayAlarm.

__gt__(other)

Method generated by attrs for class DisplayAlarm.

__init__(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, description: str = None) None

Method generated by attrs for class DisplayAlarm.

__le__(other)

Method generated by attrs for class DisplayAlarm.

__lt__(other)

Method generated by attrs for class DisplayAlarm.

__ne__(other)

Method generated by attrs for class DisplayAlarm.

__repr__()

Method generated by attrs for class DisplayAlarm.

__hash__ = None
property action

VALARM action to be implemented by concrete classes

class ics.alarm.EmailAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, summary: str = None, description: str = None, attendees: List[Attendee] = _Nothing.NOTHING, attach: List[ParseResult | bytes | None] = _Nothing.NOTHING)[source]

A calendar event VALARM with Email option.

__eq__(other)

Method generated by attrs for class EmailAlarm.

__ge__(other)

Method generated by attrs for class EmailAlarm.

__gt__(other)

Method generated by attrs for class EmailAlarm.

__init__(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, summary: str = None, description: str = None, attendees: List[Attendee] = _Nothing.NOTHING, attach: List[ParseResult | bytes | None] = _Nothing.NOTHING) None

Method generated by attrs for class EmailAlarm.

__le__(other)

Method generated by attrs for class EmailAlarm.

__lt__(other)

Method generated by attrs for class EmailAlarm.

__ne__(other)

Method generated by attrs for class EmailAlarm.

__repr__()

Method generated by attrs for class EmailAlarm.

add_attendee(attendee: Attendee)[source]

Add an attendee to the attendee list

__hash__ = None
property action

VALARM action to be implemented by concrete classes

class ics.alarm.NoneAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None)[source]

A calendar event VALARM with NONE option.

property action

VALARM action to be implemented by concrete classes

class ics.alarm.CustomAlarm(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, action: str = None)[source]

A calendar event VALARM with custom ACTION.

__eq__(other)

Method generated by attrs for class CustomAlarm.

__ge__(other)

Method generated by attrs for class CustomAlarm.

__gt__(other)

Method generated by attrs for class CustomAlarm.

__init__(trigger: timedelta | datetime | None = None, repeat: int = None, duration=None, action: str = None) None

Method generated by attrs for class CustomAlarm.

__le__(other)

Method generated by attrs for class CustomAlarm.

__lt__(other)

Method generated by attrs for class CustomAlarm.

__ne__(other)

Method generated by attrs for class CustomAlarm.

__repr__()

Method generated by attrs for class CustomAlarm.

__hash__ = None
property action

VALARM action to be implemented by concrete classes

Attendee

class ics.Attendee(email, extra=None, **kwargs)[source]

Attendee of an event or todo.

Possible values according to iCalendar standard, first value is default:

user_type = INDIVIDUAL | GROUP | RESOURCE | ROOM | UNKNOWN member = Person role = REQ-PARTICIPANT | CHAIR | OPT-PARTICIPANT | NON-PARTICIPANT rsvp = False | True delegated_to = Person delegated_from = Person

Depending on the Component, different status are possible. Event: status = NEEDS-ACTION | ACCEPTED | DECLINED | TENTATIVE | DELEGATED Todo: status = NEEDS-ACTION | ACCEPTED | DECLINED | TENTATIVE | DELEGATED | COMPLETED | IN-PROCESS

Timeline

class ics.timeline.Timeline(calendar: Calendar, normalization: Normalization | None)[source]

Timeline`s allow iterating all event from a `Calendar in chronological order, optionally also filtering events according to their timestamps.

__eq__(other)

Method generated by attrs for class Timeline.

__ge__(other)

Method generated by attrs for class Timeline.

__gt__(other)

Method generated by attrs for class Timeline.

__init__(calendar: Calendar, normalization: Normalization | None) None

Method generated by attrs for class Timeline.

__iter__() Iterator[Event][source]

Iterates on every event from the ics.icalendar.Calendar in chronological order

Note

  • chronological order is defined by the comparison operators in ics.timespan.Timespan

  • Events with no begin will not appear here. (To list all events in a Calendar use Calendar.events)

__le__(other)

Method generated by attrs for class Timeline.

__lt__(other)

Method generated by attrs for class Timeline.

__ne__(other)

Method generated by attrs for class Timeline.

__repr__()

Method generated by attrs for class Timeline.

at(instant: Tuple | Dict | datetime | date) Iterator[Event][source]

Iterates (in chronological order) over all events that are occuring during instant.

included(start: datetime | date | Timespan, stop: Tuple | Dict | datetime | date | None = None) Iterator[Event][source]

Iterates (in chronological order) over every event that is included in the timespan between start and stop. Alternatively, this method can be called directly with a single timespan as parameter.

iterator() Iterator[Tuple[Timespan, Event]][source]

Iterates on every event from the ics.icalendar.Calendar in chronological order

Note

  • chronological order is defined by the comparison operators in ics.timespan.Timespan

  • Events with no begin will not appear here. (To list all events in a Calendar use Calendar.events)

now() Iterator[Event][source]

Iterates (in chronological order) over all events that occur right now.

on(instant: Tuple | Dict | datetime | date, strict: bool = False) Iterator[Event][source]

Iterates (in chronological order) over all events that occurs on day.

Parameters:

strict – if True events will be returned only if they are strictly included in day

overlapping(start: datetime | date | Timespan, stop: Tuple | Dict | datetime | date | None = None) Iterator[Event][source]

Iterates (in chronological order) over every event that has an intersection with the timespan between start and stop. Alternatively, this method can be called directly with a single timespan as parameter.

start_after(instant: Tuple | Dict | datetime | date) Iterator[Event][source]

Iterates (in chronological order) on every event from the ics.icalendar.Calendar in chronological order. The first event of the iteration has a starting date greater (later) than instant.

today(strict: bool = False) Iterator[Event][source]

Iterates (in chronological order) over all events that occurs today.

Parameters:

strict – if True events will be returned only if they are strictly included in day

__hash__ = None
__weakref__

list of weak references to the object (if defined)