icalendar.parser.property module#

Tools for parsing properties.

icalendar.parser.property.split_on_unescaped_comma(text)[source]#

Split text on unescaped commas and unescape each part.

Splits only on commas not preceded by backslash. After splitting, unescapes backslash sequences in each part.

Parameters:

text (str) – Text with potential escaped commas (e.g., "foo\, bar,baz")

Return type:

list[str]

Returns:

List of unescaped category strings

Examples

>>> from icalendar.parser import split_on_unescaped_comma
>>> split_on_unescaped_comma(r"foo\, bar,baz")
['foo, bar', 'baz']
>>> split_on_unescaped_comma("a,b,c")
['a', 'b', 'c']
>>> split_on_unescaped_comma(r"a\,b\,c")
['a,b,c']
>>> split_on_unescaped_comma(r"Work,Personal\,Urgent")
['Work', 'Personal,Urgent']
icalendar.parser.property.split_on_unescaped_semicolon(text)[source]#

Split text on unescaped semicolons and unescape each part.

Splits only on semicolons not preceded by a backslash. After splitting, unescapes backslash sequences in each part. Used by vCard structured properties (ADR, N, ORG) per RFC 6350.

Parameters:

text (str) – Text with potential escaped semicolons (e.g., "field1\;with;field2")

Return type:

list[str]

Returns:

List of unescaped field strings

Examples

>>> from icalendar.parser import split_on_unescaped_semicolon
>>> split_on_unescaped_semicolon(r"field1\;with;field2")
['field1;with', 'field2']
>>> split_on_unescaped_semicolon("a;b;c")
['a', 'b', 'c']
>>> split_on_unescaped_semicolon(r"a\;b\;c")
['a;b;c']
>>> split_on_unescaped_semicolon(r"PO Box 123\;Suite 200;City")
['PO Box 123;Suite 200', 'City']
icalendar.parser.property.unescape_backslash(val)[source]#

Unescape backslash sequences in iCalendar text.

Unlike unescape_string(), this only handles actual backslash escapes per RFC 5545, not URL encoding. This preserves URL-encoded values like %3A in URLs.

Processes backslash escape sequences in a single pass using regex matching.

icalendar.parser.property.unescape_list_or_string(val)[source]#

Unescape a value that may be a string or list of strings.

Applies unescape_string() to the value. If the value is a list, unescapes each element.

Parameters:

val (str | list[str]) – A string or list of strings to unescape.

Return type:

str | list[str]

Returns:

The unescaped values.