icalendar.prop.categories module#

CATEGORIES property values from RFC 5545.

class icalendar.prop.categories.vCategory(c_list, /, params=None)[source]#

Bases: object

property VALUE: str#

The VALUE parameter or the default.

Purpose:

VALUE explicitly specify the value type format for a property value.

Description:

This parameter specifies the value type and format of the property value. The property values MUST be of a single value type. For example, a "RDATE" property cannot have a combination of DATE-TIME and TIME value types.

If the property's value is the default value type, then this parameter need not be specified. However, if the property's default value type is overridden by some other allowable value type, then this parameter MUST be specified.

Applications MUST preserve the value data for x-name and iana-token values that they don't recognize without attempting to interpret or parse the value data.

Returns:

The VALUE parameter or the default.

Examples

The VALUE defaults to the name of the property. Note that it is case-insensitive but always uppercase.

>>> from icalendar import vBoolean
>>> b = vBoolean(True)
>>> b.VALUE
'BOOLEAN'

Setting the VALUE parameter of a typed property usually does not make sense. For convenience, using this property, the value will be converted to an uppercase string. If you have some custom property, you might use it like this:

>>> from icalendar import vUnknown, Event
>>> v = vUnknown("Some property text.")
>>> v.VALUE = "x-type"  # lower case
>>> v.VALUE
'X-TYPE'
>>> event = Event()
>>> event.add("x-prop", v)
>>> print(event.to_ical())
BEGIN:VEVENT
X-PROP;VALUE=X-TYPE:Some property text.
END:VEVENT
__init__(c_list, /, params=None)[source]#
default_value: ClassVar[str] = 'TEXT'#
classmethod examples()[source]#

Examples of vCategory.

Return type:

list[None]

static from_ical(ical)[source]#

Parse a CATEGORIES value from iCalendar format.

This helper is normally called by Component.from_ical(), which already splits the CATEGORIES property into a list of unescaped category strings. New code should therefore pass a list of strings.

Passing a single comma-separated string is supported only for backwards compatibility with older parsing code and is considered legacy behavior.

Parameters:

ical (list[str] | str) -- A list of category strings (preferred, as provided by Component.from_ical()), or a single comma-separated string from a legacy caller.

Return type:

list[str]

Returns:

A list of category strings.

classmethod from_jcal(jcal_property)[source]#

Parse jCal from RFC 7265.

Parameters:

jcal_property (list) -- The jCal property to parse.

Raises:

JCalParsingError -- If the provided jCal is invalid.

Return type:

None

property ical_value: list[str]#

The list of categories as strings.

params: Parameters#
to_ical()[source]#
to_jcal(name)[source]#

The jCal representation for categories.

Return type:

list