Source code for ebu_tt_live.documents.base


from ebu_tt_live.utils import ComparableMixin

# NOTE: Some of the code below includes handling of SMPTE time base, which was removed from version 1.0 of the specification.

[docs]class TimeBase(object): SMPTE = 'smpte' MEDIA = 'media' CLOCK = 'clock'
[docs]class SubtitleDocument(ComparableMixin): def __init__(self): raise NotImplementedError('This is an abstract class')
[docs] def validate(self): raise NotImplementedError()
[docs]class DocumentSequence(object): """ Base class that facilitates most production-related workflows. The document stream should maintain the consistency across critical document attributes. It should maintain all sorts of counters and static information. It plays a key role in the validation of an outgoing stream of subtitle documents. """
[docs] def new_document(self, *args, **kwargs): """ Create a new document with the stream defaults :param args: :param kwargs: parameter override to constructor :return: a new document """ raise NotImplementedError()
[docs] def add_document(self, document): """ Add the document to the sequence on the consumer side of things. This will put the document on the timeline and validate the sequence in terms of timing resolution. :param document: :raises IncompatibleSequenceError meaning that the document cannot be part of this sequence for it does not match the semantics of the sequence. """ raise NotImplementedError()
[docs] def get_document(self, seq_id): """ Retrieve document by sequence number :param seq_id: :return: a document :raises: KeyError meaning the document is not in the sequence """ raise NotImplementedError()
def __getitem__(self, item): return self.get_document(seq_id=item)
[docs] def fork(self, *args, **kwargs): """ Create a new stream with modified arguments. :param args: :param kwargs: parameter override to constructor :return: a new documentstream instance """ raise NotImplementedError()
[docs]class CloningDocumentSequence(DocumentSequence): """ Base class that picks up a document and creates an appropriate stream based on it. Bear in mind continuation/revision or reproduction of a received document stream. """
[docs] @classmethod def create_from_document(cls, document, *args, **kwargs): """ Extract data from document :param document: :param args: :param kwargs: parameter override to constructor :return: """ raise NotImplementedError()