icalendar.parser.xcal.property module#

class icalendar.parser.xcal.property.XCalPropertiesParser(element, component, types_factory)[source]#

Bases: XCalParser

A parser for IC:properties.

Parameters:
  • component (Component) – Required. The component to add properties to.

  • element (Element | ElementAdapter) – Required. The xCal element to parse.

  • types_factory (TypesFactory) – Required. The types factory to use.

Example

The parameter element can be a <properties> element as shown below:

<properties>
    <prodid>
        <text>-//Example Inc.//Example Client//EN</text>
    </prodid>
    <version>
        <text>2.0</text>
    </version>
</properties>

An element in a namespace other than the iCalendar namespace becomes an XML property per RFC 6321 Section 4.1. For example, these properties contain a KML element:

<properties>
    <kml xmlns="http://www.opengis.net/kml/2.2"/>
</properties>

In iCalendar, the KML element is the value of an XML property. ElementTree chooses the namespace prefix:

XML:<ns0:kml xmlns:ns0="http://www.opengis.net/kml/2.2" />
parse_properties()[source]#

Parse multiple properties until finished.

After this call, all properties inside the parser's element parameter have been added to the component parameter. Subsequent calls do nothing.

Raises:
parse_property()[source]#

Parse one property that hasn't been parsed yet.

This function only parses one property inside the parser's element parameter and adds it to the component parameter. Each call parses a single property.

Raises:

Example

The example below shows a property that gets parsed by one call of this method:

<prodid>
    <text>-//Example Inc.//Example Client//EN</text>
</prodid>
class icalendar.parser.xcal.property.XCalPropertyParser(element, types_factory=None)[source]#

Bases: XCalParameterParser

A parser for one property.

This parses the value type and additionally the parameters.

Parameters:
Raises:

XCalParsingError – If the provided xCal is invalid.

Examples

The parameter element can be a <prodid> element with a single text value, as shown below:

<prodid>
    <text>-//Example Inc.//Example Client//EN</text>
</prodid>

Some elements, such as <rdate> and <categories>, can contain multiple values. This is illustrated in the example below:

<categories>
    <text>Work</text>
    <text>Home</text>
</categories>

Within an element, a property can contain parameters. These parameters apply to all values. The example below shows a <date-time> value in the timezone US/Eastern.

<dtstart>
    <parameters>
        <tzid>
            <text>US/Eastern</text>
        </tzid>
    </parameters>
    <date-time>2021-01-01T00:00:00</date-time>
</dtstart>
initialize_parameters()[source]#

Parse the parameters, if present.

Parameters need to be parsed only once. This method parses the <parameters> element inside the property.

Return type:

Parameters

Returns:

If there are parameters, they are returned as parsed. Otherwise, an empty Parameters object is returned.

Raises:

XCalParsingError – If the provided xCal is invalid.

parse_parameters()[source]#

Return the parsed parameters.

Return type:

Parameters

Returns:

The parsed parameters. Parameters are identical for all property values.

parse_property_value()[source]#

Parse one property value that hasn't been parsed yet.

Return type:

vAdr | vBoolean | vBroken | vCalAddress | vCategory | vDDDLists | vDDDTypes | vDate | vDatetime | vDuration | vFloat | vFrequency | vInt | vMonth | vN | vOrg | vPeriod | vRecur | vSkip | vText | vTime | vUTCOffset | vUri | vWeekday | vInline | vBinary | vGeo | vUnknown | vXmlReference | vXml | vUid | vRequestStatus

Returns:

The parsed property value.

Raises:

Example

The example below shows a <text> element that this method can parse into a vText.

<text>-//Example Inc.//Example Client//EN</text>