Custom properties¶
ics.py does not indeed support the full rfc5545 specification and most likely, it will never do as it is too much work. Also, there are as many extensions to the RFC as there are implementations of iCalendar creators so it would be impossible to support every existing property.
The way around this limitation is that every ics.parse.Container
(Event
, Todo
and even Calendar
inherit from Container
)
has a .extra
attribute.
At parsing time, every property or container that is unknown to ics.py
(and thus not handled) is stored in .extra
. The other way, everything
in .extra
is serialized when outputting data.
Let’s say that we have an input like this (indentation is for illustration purposes):
BEGIN:VEVENT
SUMMARY:Name of the event
FOO:BAR
END:VEVENT
It will result in an event that will have the following characteristics:
e.name == "Name of the event"
e.extra == [ContentLine(name="FOO", value="BAR")]
In a more complicated situation, you might even have something like this:
BEGIN:VEVENT
SUMMARY:Name of the event
BEGIN:FOO
BAR:MISC
END:FOO
THX:BYE
END:VEVENT
It will result in an event that will have a ics.parse.Container
in .extra
:
e.name == "Name of the event"
e.extra == [
Container(name="FOO", ContentLine(name="BAR", value="MISC")),
ContentLine(name="THX", value="BYE"),
]
.extra
is mutable so this means it works in reverse too.
Just add some Container
or
ics.parse.ContentLine
and they will appear in the output too.
(You can even mutate the values of a specific ContentLine
if you desire)
Low level API¶
- class ics.contentline.container.Container(name, data=[])[source]¶
Represents an iCalendar object. Contains a list of ContentLines or Containers.
- Parameters:
name – the name of the object (VCALENDAR, VEVENT etc.)
items – Containers or ContentLines
- clear()¶
Remove all items from list.
- count(value, /)¶
Return number of occurrences of value.
- extend(values)[source]¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- pop(index=-1, /)¶
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)¶
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()¶
Reverse IN PLACE.