icalendar.prop.unknown module#
UNKNOWN values from RFC 7265.
- class icalendar.prop.unknown.vUnknown(value, encoding='utf-8', /, params=None)[source]#
Bases:
strA property value of the RFC 7265 Section 5 reserved UNKNOWN value data type.
Changed in version 7.2.0: Previously
vUnknowninherited fromvText, which unescapes values. NowvUnknowndoesn'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:
See also
- 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.
- 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.
- encoding#
- 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_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:
- 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 7265UNKNOWNvalues, the escaping rules of the real value type are not known, so no unescaping can be applied.- Return type:
- params: Parameters#
- to_ical()[source]#
Return the value verbatim, without RFC 5545 escaping.
This method's implementation is different from that in
vText, whoseto_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'
See also
- Return type:
- 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: