API¶
Calendar¶
-
class
ics.icalendar.
Calendar
(imports=None, events=None, todos=None, creator=None)[source]¶ Represents an unique rfc5545 iCalendar.
-
__init__
(imports=None, events=None, todos=None, creator=None)[source]¶ Instantiates a new Calendar.
Parameters: If imports is specified, every other argument will be ignored.
-
__iter__
()[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.append(Event(name="My cool event")) >>> open('my.ics', 'w').writelines(c)
-
__urepr__
()[source]¶ Returns: representation (__repr__) of the calendar. Return type: unicode Should not be used directly. Use self.__repr__ instead.
-
creator
¶ Get or set the calendar’s creator.
Will return a string.May be set to a string.Creator is the PRODID iCalendar property.It uniquely identifies the program that created the calendar.
-
Event¶
-
class
ics.event.
Event
(name=None, begin=None, end=None, duration=None, uid=None, description=None, created=None, location=None, url=None, transparent=False, alarms=None, categories=None)[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.
-
__and__
(other, *args, **kwarg)¶ Create a new event which covers the time range of two intersecting events
All extra parameters are passed to the Event constructor.
Parameters: other – the other event Returns: a new Event instance
-
__init__
(name=None, begin=None, end=None, duration=None, uid=None, description=None, created=None, location=None, url=None, transparent=False, alarms=None, categories=None)[source]¶ Instantiates a new
ics.event.Event
.Parameters: - name (string) – rfc5545 SUMMARY property
- begin (Arrow-compatible) –
- end (Arrow-compatible) –
- duration (datetime.timedelta) –
- uid (string) – must be unique
- description (string) –
- created (Arrow-compatible) –
- location (string) –
- url (string) –
- transparent (Boolean) –
:param alarms (
ics.alarm.Alarm
: :param categories: :type categories: set of stringRaises: ValueError
– if end and duration are specified at the same time
-
__urepr__
()[source]¶ Should not be used directly. Use self.__repr__ instead.
Returns: a unicode representation (__repr__) of the event. Return type: unicode
-
join
(other, *args, **kwarg)[source]¶ Create a new event which covers the time range of two intersecting events
All extra parameters are passed to the Event constructor.
Parameters: other – the other event Returns: a new Event instance
-
make_all_day
()[source]¶ Transforms self to an all-day event.
The event will span all the days from the begin to the end day.
-
begin
¶ Get or set the beginning of the event.
Will return anArrow
object.May be set to anything thatArrow.get()
understands.If an end is defined (not a duration), .begin must not be set to a superior value.
-
duration
¶ Get or set the duration of the event.
Will return a timedelta object.May be set to anything that timedelta() understands.May be set with a dict ({“days”:2, “hours”:6}).If set to a non null value, removes any already existing end time.
-
end
¶ Get or set the end of the event.
Will return anArrow
object.May be set to anything thatArrow.get()
understands.If set to a non null value, removes any already existing duration.Setting to None will have unexpected behavior if begin is not None.Must not be set to an inferior value than self.begin.
-
Alarm¶
-
class
ics.alarm.
Alarm
(trigger=None, repeat=None, duration=None)[source]¶ A calendar event VALARM base class
-
__extra_urepr__
()[source]¶ Should not be used directly. Used with self.__repr__.
Returns: a unicode representation (__repr__) of the alarm. Return type: unicode
-
__init__
(trigger=None, repeat=None, duration=None)[source]¶ Instantiates a new
ics.alarm.Alarm
.Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html
Parameters: - trigger (datetime.timedelta OR datetime.datetime) – Timespan to alert before parent action, or absolute time to alert
- repeat (integer) – How many times to repeat the alarm
- duration (datetime.timedelta) – Duration between repeats
Raises: ValueError
– If trigger, repeat, or duration do not match the RFC spec.
-
__urepr__
()[source]¶ Should not be used directly. Use self.__repr__ instead.
Returns: a unicode representation (__repr__) of the alarm. Return type: unicode
-
action
¶ VALARM action to be implemented by concrete classes
-
duration
¶ Duration between alarm repeats
Returns a timedelta objectTimespan must return positive total_seconds() value
-
repeat
¶ Number of times to repeat alarm
Returns an integer for number of alarm repeatsValue must be >= 0
-
trigger
¶ The trigger condition for the alarm
Returns either a timedelta or datetime objectTimedelta must have positive total_seconds()Datetime object is also allowed.
-
DisplayAlarm¶
-
class
ics.alarm.
DisplayAlarm
(description=None, **kwargs)[source]¶ A calendar event VALARM with DISPLAY option.
-
__extra_urepr__
()[source]¶ Should not be used directly. Used with self.__repr__.
Returns: a unicode representation (__repr__) of the alarm. Return type: unicode
-
__init__
(description=None, **kwargs)[source]¶ Instantiates a new
ics.alarm.DisplayAlarm
.Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html
Parameters: - description (string) – RFC5545 DESCRIPTION property
- kwargs (dict) – Args to
ics.alarm.Alarm.__init__()
-
AudioAlarm¶
-
class
ics.alarm.
AudioAlarm
(attach=None, attach_params=None, **kwargs)[source]¶ A calendar event VALARM with AUDIO option.
-
__extra_urepr__
()[source]¶ Should not be used directly. Used with self.__repr__.
Returns: a unicode representation (__repr__) of the alarm. Return type: unicode
-
__init__
(attach=None, attach_params=None, **kwargs)[source]¶ Instantiates a new
ics.alarm.AudioAlarm
.Adheres to RFC5545 VALARM standard: http://icalendar.org/iCalendar-RFC-5545/3-6-6-alarm-component.html
Parameters: - attach (string) – RFC5545 ATTACH property, pointing to an audio object
- attach_params (dict) – RFC5545 attachparam values
- kwargs (dict) – Args to
ics.alarm.Alarm.__init__()
-
Timeline¶
-
class
ics.timeline.
Timeline
(calendar)[source]¶ -
__init__
(calendar)[source]¶ Instanciates a new Timeline. (You should not have to instanciate a new timeline by yourself)
Parameters: calendar – ics.icalendar.Calendar
-
__iter__
()[source]¶ Iterates on every event from the
ics.icalendar.Calendar
in chronological order- Note :
- chronological order is defined by the comparaison operators in
ics.event.Event
- Events with no begin will not appear here. (To list all events in a Calendar use Calendar.events)
- chronological order is defined by the comparaison operators in
-
at
(instant)[source]¶ Iterates (in chronological order) over all events that are occuring during instant.
Parameters: instant (Arrow object) –
-
included
(start, stop)[source]¶ Iterates (in chronological order) over every event that is included in the timespan between start and stop
Parameters: - start – (Arrow object)
- stop – (Arrow object)
-
on
(day, strict=False)[source]¶ Iterates (in chronological order) over all events that occurs on day
Parameters: - day (Arrow object) –
- strict (bool) – if True events will be returned only if they are strictly included in day.
-
overlapping
(start, stop)[source]¶ Iterates (in chronological order) over every event that has an intersection with the timespan between start and stop
Parameters: - start – (Arrow object)
- stop – (Arrow object)
-
start_after
(instant)[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 instantParameters: instant – (Arrow object) starting point of the iteration
-
today
(strict=False)[source]¶ Iterates (in chronological order) over all events that occurs today
Parameters: strict (bool) – if True events will be returned only if they are strictly included in day.
-
__weakref__
¶ list of weak references to the object (if defined)
-