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
Subpackages¶
- bindings Package
- carriage Package
- clocks Package
- config Package - Component configurators
- documents Package
- examples Package
- node Package
- scripts Package
- twisted Package
errors
Module¶
-
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.
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.
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.
-
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.
-
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.
-
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.
-
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"