icalendar.parser.content_line module#

parsing and generation of content lines

class icalendar.parser.content_line.Contentline(value, strict=False, encoding='utf-8')[source]#

Bases: str

A content line is basically a string that can be folded and parsed into parts.

classmethod from_ical(ical, strict=False)[source]#

Unfold the content lines in an iCalendar into long content lines.

classmethod from_parts(name, params, values, sorted=True)[source]#

Turn a parts into a content line.

parts(should_unescape=True)[source]#

Split the content line into name, parameters, and values parts.

Properly handles escaping with backslashes and double-quote sections to avoid corrupting URL-encoded characters in values.

When should_unescape is True, unescape backslashes. This is used for the values of TEXT properties.

When should_unescape is False the value is returned raw, without backslash unescaping. This is used for RFC 7265 UNKNOWN values, which must be preserved verbatim.

The default is True.

Example with parameter:

DESCRIPTION;ALTREP="cid:part1.0001@example.org":The Fall'98 Wild

Example without parameters:

DESCRIPTION:The Fall'98 Wild
Return type:

tuple[str, Parameters, str]

strict#
to_ical()[source]#

Long content lines are folded so they are less than 75 characters wide.

class icalendar.parser.content_line.Contentlines(iterable=(), /)[source]#

Bases: list[Contentline]

I assume that iCalendar files generally are a few kilobytes in size. Then this should be efficient. for Huge files, an iterator should probably be used instead.

classmethod from_ical(st)[source]#

Parses a string into content lines.

to_ical()[source]#

Simply join self.