icalendar.parser.xcal.adapter module#

class icalendar.parser.xcal.adapter.ChildElementAdapter(child, parent, index=1)[source]#

Bases: ElementAdapter

An adapter class with convenience methods for child elements.

Parameters:
  • child (Element) – The child element.

  • index (int) – The index for building the XPath in the parent.

  • parent (ElementAdapter) – The parent element adapter.

get_xpath()[source]#

Return the path in the XML file where this element occurs.

Return type:

str

property parent: ElementAdapter#

The parent element.

class icalendar.parser.xcal.adapter.ElementAdapter(element)[source]#

Bases: object

An adapter class with convenience methods for XML elements.

This is a read-only access adapter. All operations on ElementAdapter are reproducible and do not change the underlying element.

property children: list[ChildElementAdapter]#

A list of child elements.

property element: Element#

The underlying element.

get_child_with_tag(tag)[source]#

Get the first child element with the given tag.

Return type:

ChildElementAdapter | None

get_inner_text()[source]#

Return the inner text.

This is useful when there is a broken property.

Return type:

str

get_text_without_whitespace()[source]#

Return the element's text with all whitespace removed.

Return type:

str

get_xpath()[source]#

Return the path in the XML file where this element occurs.

Return type:

str

get_xsd_float()[source]#

Return the element's text parsed as xsd:float.

Return type:

float

Returns:

The parsed float value.

Raises:

XCalParsingError – If the value is not a float.

get_xsd_string()[source]#

Return the element's text as xsd:string.

This is the only datatype that leaves all the whitespace.

See also

xmlschemata.org

Return type:

str

get_xsd_token()[source]#

Return the element's text as xsd:token.

xsd:token is the most appropriate datatype to use for strings that don't care about whitespace.

See also

xmlschemata.org

Return type:

str

property is_extension: bool#

Whether the element is in a namespace other than the iCalendar namespace.

Elements without a namespace belong to iCalendar. Extension elements directly in properties are XML properties.

Returns:

True for an element outside the iCalendar namespace, or False for an element either in the iCalendar namespace or without a namespace.

make_parent(tag)[source]#

Return an element adapter for a parent.

Return type:

ElementAdapter

parse_tag(tag)[source]#

Get the first child element with the given tag.

Returns:

The first child element with the given tag.

Raises:

XCalParsingError – If the tag is not found.

property tag: str#

A sanitized element tag.

classmethod with_element(element)[source]#

Create a new element adapter or return the present one.

Return type:

ElementAdapter