Source code reference

The toolkit is implemented inside the ebu_tt_live python package. The following reference helps to get an insight of what the different components and classes are responsible for.

Layout of the source files

The sources comprise subpackages and submodules to create a modular system that can be configured as required by the user. The very quick overview before the generated source code reference hopefully helps find one’s bearings faster.

Code Structure :

ebu_tt_live
├─bindings - PyXB based bindings and custom code that provides advanced validation functionality
│ ├─raw - Low-level PyXB generated code based on the XSD schema definitions in ebu_tt_live/xsd
│ ├─converters - Low-level converters to convert bindings from one schema to another
│ ├─validation - Custom extension python mixins that are used for adding semantic validation functionality to binding types
│ └*.py - Custom extension code importing bindings from the raw package and enhancing them with extra functions such as validation capability
├─carriage - Carriage Mechanism classes to be used by the Nodes
├─clocks - Various reference clock implementations
├─config - Component configurators
├─documents - Document wrapper classes wrapping bindings into an less cluttered interface
├─examples - Built-in data files that are used to make the tools easier to run
├─node - Processing node code mostly on the document level independent on carriage mechanism implementation
├─scripts - Console scripts that make things easier to run
├─twisted - Carriage implementations using the twisted framework(currently websocket server and client classes)
├─ui - Files needed to run the User Input Producer webapp
├─xsd - Schema definitions
├errors.py - Custom Exception types for the Toolkit
├strings.py - Various error and response strings in t translatable format all in one place for easy translation
└utils.py - Standalone utilities independent from the live toolkit but used by the toolkit for some tasks

errors Module

exception ebu_tt_live.errors.ComponentCompatError[source]

Bases: exceptions.TypeError

exception ebu_tt_live.errors.ConfigurationError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.DataCompatError[source]

Bases: exceptions.TypeError

exception ebu_tt_live.errors.DiscardElement[source]

Bases: exceptions.Exception

There is a possibility that an element may become superfluous or lose its value. Such a possibility can happen in segmentation when a p element gets selected because it contains 2 spans but the segment happens to be selecting an interval between them so the container ends up being empty and thus should be discarded.

exception ebu_tt_live.errors.DocumentDiscardedError[source]

Bases: exceptions.Exception

offending_document = None
exception ebu_tt_live.errors.DocumentNotLoadedError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.EndOfData[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.ExtentMissingError(attribute)[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.IncompatibleSequenceError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.LogicError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.OutsideSegmentError[source]

Bases: ebu_tt_live.errors.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.

exception ebu_tt_live.errors.SemanticValidationError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.SequenceNumberCollisionError[source]

Bases: ebu_tt_live.errors.IncompatibleSequenceError

exception ebu_tt_live.errors.SequenceOverridden[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.StopBranchIteration[source]

Bases: exceptions.Exception

Let the iterator know that it can proceed to the next branch. It does not need to traverse the current one any further.

exception ebu_tt_live.errors.TimeFormatError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.TimeFormatOverflowError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.UnexpectedAuthorsGroupError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.UnexpectedSequenceIdentifierError[source]

Bases: exceptions.Exception

exception ebu_tt_live.errors.XMLParsingFailed[source]

Bases: exceptions.Exception

strings Module

utils Module

class ebu_tt_live.utils.AbstractStaticMember(validation_func=None)[source]

Bases: object

This allows me to require the subclasses to define some attributes using a customizeable validator. The idea is that all static members should be initialized to a value by the time abstract functions have all been implemented.

validate(value, member_name, class_name)[source]
class ebu_tt_live.utils.AnyType[source]

Bases: object

A helper object that compares equal to everything.

class ebu_tt_live.utils.AutoRegisteringABCMeta[source]

Bases: abc.ABCMeta

This metaclass gets us automatic class registration and cooperates with AbstractStaticMember. If none of the 2 features are needed it just provides the basic abc.ABCMeta functionality. For the auto registration an abstract class needs to implement the auto_register_impl classmethod.

class ebu_tt_live.utils.ComparableMixin[source]

Bases: object

This mixin is meant to make implementing the comparison interface easier without having to clutter up custom class implementations that would only like to delegate their comparison to comparable a member. This class is Python3 compatible. NOTE: This is a slightly modified version of the one suggested by the following blog: https://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

class ebu_tt_live.utils.RingBufferWithCallback(iterable=(), maxlen=None, callback=None)[source]

Bases: collections.deque

This class calls a callback when an item is falling out of the buffer due to removal. On manual removal it does not. That is the user’s responsibility.

append(item)[source]

Add an element to the right side of the deque.

class ebu_tt_live.utils.RotatingFileBuffer(maxlen, async=True)[source]

Bases: ebu_tt_live.utils.RingBufferWithCallback

This class holds the given number of file names and when they are pushed out of the buffer it deletes them asynchronously. Preferably just the names and not open file handles.

append(item)[source]

This override makes sure that we don’t add to an asynchronously managed buffer that is about to be shut down. :param item: The file name :return:

delete_file(item)[source]

This function hands the file down to our worker thread to deal with it. :param item: :return:

exception ebu_tt_live.utils.RotatingFileBufferStopped[source]

Bases: exceptions.Exception

class ebu_tt_live.utils.StoppableThread(*args, **kwargs)[source]

Bases: threading.Thread

Thread class with a stop() method. The thread itself has to check regularly for the stopped() condition.

stop()[source]
stopped()[source]
ebu_tt_live.utils.compare_xml(want, got)[source]

Tries to do a ‘xml-comparison’ of want and got. Plain string comparison doesn’t always work because, for example, attribute ordering should not be important. Comment nodes are not considered in the comparison. Leading and trailing whitespace is ignored on both chunks.

Based on https://github.com/lxml/lxml/blob/master/src/lxml/doctestcompare.py

This function is a close but not full implementation of fn:deep-equals. Possible scenario where this will yield a false positive result is where an element can have 2 arguments with the same name but different namespaces:

i.e.: <elem ns1:myattr=”1” /> != <elem ns2:myattr=”1” /> if ns1 != ns2
ebu_tt_live.utils.strip_quotes(want, got)[source]

Strip quotes of doctests output values:

>>> strip_quotes("'foo'")
"foo"
>>> strip_quotes('"foo"')
"foo"
ebu_tt_live.utils.tokenize_english_document(input_text)[source]

This is a crude tokenizer for input conversations in English. :param input_text: :return:

ebu_tt_live.utils.validate_types_only(value, member_name, class_name)[source]