icalendar.parser.xcal.property module#
- class icalendar.parser.xcal.property.XCalPropertiesParser(element, component, types_factory)[source]#
Bases:
XCalParserA 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
elementcan 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.
ElementTreechooses 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
elementparameter have been added to thecomponentparameter. Subsequent calls do nothing.- Raises:
XCalParsingError – If the provided xCal is invalid.
InvalidParserState – If all properties have been parsed, a property value type parsed nothing.
- parse_property()[source]#
Parse one property that hasn't been parsed yet.
This function only parses one property inside the parser's
elementparameter and adds it to thecomponentparameter. Each call parses a single property.- Raises:
XCalParsingError – If the provided xCal is invalid.
InvalidParserState – If all properties have been parsed, a property value type parsed nothing.
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:
XCalParameterParserA parser for one property.
This parses the value type and additionally the parameters.
- Parameters:
element (
Element|ElementAdapter) – Required. The xCal element to parse.types_factory (
TypesFactory|None) – The types factory to use. IfNoneis passed, the defaultTypesFactoryis used.
- Raises:
XCalParsingError – If the provided xCal is invalid.
Examples
The parameter
elementcan be a <prodid> element with a singletextvalue, 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:
- Returns:
If there are parameters, they are returned as parsed. Otherwise, an empty
Parametersobject is returned.- Raises:
XCalParsingError – If the provided xCal is invalid.
- parse_parameters()[source]#
Return the parsed parameters.
- Return type:
- 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:
XCalParsingError – If the provided xCal is invalid.
InvalidParserState – If all properties have been parsed or a property value parsed nothing.
Example
The example below shows a <text> element that this method can parse into a
vText.<text>-//Example Inc.//Example Client//EN</text>