icalendar.parser.xcal.base module#

xCal parser class to fully parse the content.

exception icalendar.parser.xcal.base.InvalidParserState[source]#

Bases: Exception

The parser is in an invalid state.

This exception should never be raised in production code.

class icalendar.parser.xcal.base.XCalParser(element)[source]#

Bases: object

Create a new XCalParser that takes care of the parsing state.

An element is passed to the parser. The element and its child elements can be inspected and marked as parsed.

property child: ChildElementAdapter#

Get the next child element.

Raises:

InvalidParserState – If there are no more children.

done()[source]#

Done with this child element.

Raises:

InvalidParserState – If there are no more children.

property element: ElementAdapter#

The element to parse.

ensure_tag_is_present(tag)[source]#

Check for the presence of a tag that has not yet been parsed.

This serves as a check before parse_tag(). The returned tag is not marked as parsed.

Return type:

str

Returns:

The tag that is present.

Raises:

XCalParsingError – If the tag is not found.

is_finished()[source]#

Whether there are more elements left to parse.

Return type:

bool

parse_optional_tag(tag)[source]#

Find a child tag and return it if present, else None.

This child is then considered parsed.

Return type:

ElementAdapter | None

parse_parameters()[source]#

Return empty parameters.

This can be changed in subclasses.

Return type:

Parameters

parse_tag(tag=None)[source]#

Find a child tag and return it.

This child is then considered parsed.

Return type:

ElementAdapter

Returns:

The child element with the tag, or if no tag is given, then the first child.

Raises:

XCalParsingError – If the tag is not found.

parse_tags(tag)[source]#

Find all child tags and return it.

These children is then considered parsed.

Return type:

list[ElementAdapter]

property tag: str#

The tag of the element on which to work.