icalendar.prop.unknown module#

UNKNOWN values from RFC 7265.

class icalendar.prop.unknown.vUnknown(value, encoding='utf-8', /, params=None)[source]#

Bases: str

A property value of the RFC 7265 Section 5 reserved UNKNOWN value data type.

Changed in version 7.2.0: Previously vUnknown inherited from vText, which unescapes values. Now vUnknown doesn't unescape its values, which is the correct behavior.

Unlike vText, the value is preserved verbatim when imported from and exported to iCalendar data, without RFC 5545 escaping or unescaping. When the value type of an unrecognized property is not known, then no escaping rules can be applied, and the value must be preserved as is round-trip.

For RFC 6321, vUnknown plays an important role in preserving the VALUE parameter.

>>> from icalendar import Calendar, vUnknown
>>> cal = Calendar()
>>> cal.add("X-PROP", vUnknown("lalala", params={"VALUE": "X-VALUE"}))
>>> print(cal.to_xcal(indent=2).decode("utf-8"))
<?xml version="1.0" encoding="UTF-8"?>
<icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0">
  <vcalendar>
    <properties>
      <x-prop>
        <x-value>lalala</x-value>
      </x-prop>
    </properties>
  </vcalendar>
</icalendar>
Parameters:
  • value (str | bytes) – Required. The value of the unknown property.

  • encoding (str) – The encoding of the value. Default is DEFAULT_ENCODING.

  • params (dict[str, Any] | None) – The parameters of the property.

property ALTREP: str | None#

ALTREP - Specify an alternate text representation for the property value.

Description:

This parameter specifies a URI that points to an alternate representation for a textual property value. A property specifying this parameter MUST also include a value that reflects the default representation of the text value. The URI parameter value MUST be specified in a quoted-string.

Note

While there is no restriction imposed on the URI schemes allowed for this parameter, Content Identifier (CID) RFC 2392, HTTP RFC 2616, and HTTPS RFC 2818 are the URI schemes most commonly used by current implementations.

property LANGUAGE: str | None#

Specify the language for text values in a property or property parameter.

Description:

This parameter identifies the language of the text in the property value and of all property parameter values of the property. The value of the "LANGUAGE" property parameter is that defined in RFC 5646.

For transport in a MIME entity, the Content-Language header field can be used to set the default language for the entire body part. Otherwise, no default language is assumed.

property RELTYPE: RELTYPE#

Specify the type of hierarchical relationship associated with a component.

Conformance:

RFC 5545 introduces the RELTYPE property parameter. RFC 9253 adds new values.

Description:

This parameter can be specified on a property that references another related calendar. The parameter specifies the hierarchical relationship type of the calendar component referenced by the property. The parameter value can be PARENT, to indicate that the referenced calendar component is a superior of calendar component; CHILD to indicate that the referenced calendar component is a subordinate of the calendar component; or SIBLING to indicate that the referenced calendar component is a peer of the calendar component. If this parameter is not specified on an allowable property, the default relationship type is PARENT. Applications MUST treat x-name and iana-token values they don't recognize the same way as they would the PARENT value.

Setter accepts:

str | None

default_value: ClassVar[str] = 'UNKNOWN'#
encoding#
classmethod examples()[source]#

Examples of vUnknown.

Return type:

list[Self]

classmethod from_first_xcal_element(xml)[source]#

Parse xCal according to RFC 6321.

This class is used as a fallback if no other type can parse this xCal.

Parameters:
  • parser – Required. The xCal to parse or a parser.

  • params – Required. The parameters of the xCal element.

Raises:

XCalParsingError – If the provided xCal is invalid.

Return type:

VProp

classmethod from_ical(ical)[source]#

Take the value verbatim, without unescaping.

Return type:

Self

classmethod from_jcal(jcal_property)[source]#

Parse jCal from RFC 7265, taking the value verbatim.

Parameters:

jcal_property (list) – The jCal property to parse.

Raises:

JCalParsingError – If the provided jCal is invalid.

Return type:

Self

classmethod from_xcal(xml)[source]#

Parse xCal according to RFC 6321.

Parameters:
  • parser – Required. The xCal to parse or a parser.

  • params – Required. The parameters of the xCal element.

Raises:

XCalParsingError – If the provided xCal is invalid.

Return type:

VProp

classmethod get_value_from_content_line(line)[source]#

Return this type's value from line, taken verbatim.

Value types that must not have their value unescaped provide this method, and the parser uses it to obtain the value instead of parts(). For RFC 7265 UNKNOWN values, the escaping rules of the real value type are not known, so no unescaping can be applied.

Return type:

str

property ical_value: str#

The string value of the property.

params: Parameters#
classmethod parse_jcal_value(jcal_value)[source]#

Parse a jCal value into a vUnknown.

Return type:

Self

to_ical()[source]#

Return the value verbatim, without RFC 5545 escaping.

This method's implementation is different from that in vText, whose to_ical() method escapes ;, ,, \, and newlines.

Example

The semicolon is kept verbatim for UNKNOWN, unlike a TEXT value which would escape it as \\;.

>>> from icalendar.prop import vText, vUnknown
>>> vUnknown("a;b").to_ical()
b'a;b'
>>> vText("a;b").to_ical()
b'a\\;b'
Return type:

bytes

to_jcal(name)[source]#

The jCal representation of this property, according to RFC 7265 Section 5.1.

If the property doesn't include a VALUE property parameter and its value type is not known, then its value type is set to "unknown". Else the property's value type is converted to lowercase.

The property's value is the unprocessed value text, aside from standard JSON string escaping.

Return type:

list

to_xcal(element)[source]#

Add the xCal representation of this property according to RFC 6321.

Return type:

None