icalendar.parser.xcal.match module#

Consistent error reporting and matching of xCal element content.

class icalendar.parser.xcal.match.XCalRegexMatcher(regex, expected_message, flags=0)[source]#

Bases: object

Match a regex and provide consistent error messages.

Parameters:
  • regex (str | Pattern) – The regex to match.

  • expected_message (str) – The start of the error message saying what is expected.

  • flags (int) – The regex flags to use. Only used of regex is a string.

groups(element)[source]#

Return the match groups for the element's text.

Parameters:

element (ElementAdapter) – The element to match the text from.

Return type:

tuple[str, ...]

Returns:

The groups of the match if successful.

Raises:

XCalParsingError – If the provided xCal is invalid.

match(element)[source]#

Return the match for the element's text.

Parameters:

element (ElementAdapter) – The element to match the text from.

Return type:

Match

Returns:

The match if successful.

Raises:

XCalParsingError – If the provided xCal is invalid.