# Path: ebu_tt_live/bindings/pyxb_utils.py
# def get_xml_parsing_context():
#     """
#     The parsing context is a simple python dictionary that helps tie together semantic rules at parsing time.
# 
#     For example: making sure that limitedClockTimingtype and fullClockTimingType are instantiated appropriately taking
#     into account the timeBase attribute on the tt element. In that case when the timeBase element is encountered by the
#     parser is is added to the parsing context object to help PyXB make the right type in the timingType union.
# 
#     :return: dict that is te parsing context for the currently running parser
#     :return: None if not in parsing mode
#     """
#     log.debug('Accessing xml_parsing_context: {}'.format(__xml_parsing_context))
#     if __xml_parsing_context.parsing is False:
#         # We are not in parsing mode
#         return None
#     return __xml_parsing_context.context
# 
# Path: ebu_tt_live/errors.py
# class LogicError(Exception):
#     pass
# 
# class SemanticValidationError(Exception):
#     pass
# 
# class OutsideSegmentError(StopBranchIteration):
#     """
#     This exception is meant to be raised by the copying functionality to make the iterator know that a particular
#     subtree is not meant to be parsed.
#     """
# 
# Path: ebu_tt_live/strings.py
# ERR_SEMANTIC_VALIDATION_TIMING_TYPE = gettext('{attr_type}({attr_value}) is not a valid type for {attr_name} in timeBase={time_base}')


from datetime import timedelta
from ebu_tt_live.bindings import get_xml_parsing_context
from ebu_tt_live.errors import LogicError, SemanticValidationError, OutsideSegmentError
from ebu_tt_live.strings import ERR_SEMANTIC_VALIDATION_TIMING_TYPE
                                  [x.value for x in self.orderedContent()])

            self._post_calculate_begin(children=children)

        self._post_cleanup_variables()

    # The mixin approach is used since there are multiple timed element types.
    # The inspected values are all attributes of the element so they do not
    # take part in the traversal directly we process them in the timed element's context instead: body, div, p, span
    def _semantic_timebase_validation(self, dataset, element_content):
        time_base = dataset['tt_element'].timeBase
        if self.begin is not None:
            if hasattr(self.begin, 'compatible_timebases'):
                # Check typing of begin attribute against the timebase
                timebases = self.begin.compatible_timebases()
                if time_base not in timebases['begin']:
                    raise SemanticValidationError(
                        ERR_SEMANTIC_VALIDATION_TIMING_TYPE.format(
                            attr_type=type(self.begin),
                            attr_value=self.begin,
                            attr_name='begin',
                            time_base=time_base
                        )
                    )
        if self.end is not None:
            if hasattr(self.end, 'compatible_timebases'):
                # Check typing of end attribute against the timebase
                timebases = self.end.compatible_timebases()
                if time_base not in timebases['end']:
                    raise SemanticValidationError(

# Path: ebu_tt_live/bindings/pyxb_utils.py
# def get_xml_parsing_context():
#     """
#     The parsing context is a simple python dictionary that helps tie together semantic rules at parsing time.
# 
#     For example: making sure that limitedClockTimingtype and fullClockTimingType are instantiated appropriately taking
#     into account the timeBase attribute on the tt element. In that case when the timeBase element is encountered by the
#     parser is is added to the parsing context object to help PyXB make the right type in the timingType union.
# 
#     :return: dict that is te parsing context for the currently running parser
#     :return: None if not in parsing mode
#     """
#     log.debug('Accessing xml_parsing_context: {}'.format(__xml_parsing_context))
#     if __xml_parsing_context.parsing is False:
#         # We are not in parsing mode
#         return None
#     return __xml_parsing_context.context
# 
# Path: ebu_tt_live/errors.py
# class LogicError(Exception):
#     pass
# 
# class SemanticValidationError(Exception):
#     pass
# 
# class OutsideSegmentError(StopBranchIteration):
#     """
#     This exception is meant to be raised by the copying functionality to make the iterator know that a particular
#     subtree is not meant to be parsed.
#     """
# 
# Path: ebu_tt_live/strings.py
# ERR_SEMANTIC_VALIDATION_TIMING_TYPE = gettext('{attr_type}({attr_value}) is not a valid type for {attr_name} in timeBase={time_base}')


# Path: ebu_tt_live/bindings/validation/timing.py
from datetime import timedelta
from ebu_tt_live.bindings import get_xml_parsing_context
from ebu_tt_live.errors import LogicError, SemanticValidationError, OutsideSegmentError
from ebu_tt_live.strings import ERR_SEMANTIC_VALIDATION_TIMING_TYPE

                                  [x.value for x in self.orderedContent()])

            self._post_calculate_begin(children=children)

        self._post_cleanup_variables()

    # The mixin approach is used since there are multiple timed element types.
    # The inspected values are all attributes of the element so they do not
    # take part in the traversal directly we process them in the timed element's context instead: body, div, p, span
    def _semantic_timebase_validation(self, dataset, element_content):
        time_base = dataset['tt_element'].timeBase
        if self.begin is not None:
            if hasattr(self.begin, 'compatible_timebases'):
                # Check typing of begin attribute against the timebase
                timebases = self.begin.compatible_timebases()
                if time_base not in timebases['begin']:
                    raise SemanticValidationError(
                        ERR_SEMANTIC_VALIDATION_TIMING_TYPE.format(
                            attr_type=type(self.begin),
                            attr_value=self.begin,
                            attr_name='begin',
                            time_base=time_base
                        )
                    )
        if self.end is not None:
            if hasattr(self.end, 'compatible_timebases'):
                # Check typing of end attribute against the timebase
                timebases = self.end.compatible_timebases()
                if time_base not in timebases['end']:
                    raise SemanticValidationError(

                        ERR_SEMANTIC_VALIDATION_TIMING_TYPE.format(