documents Package¶
documents
Package¶
base
Module¶
-
class
ebu_tt_live.documents.base.
CloningDocumentSequence
[source]¶ Bases:
ebu_tt_live.documents.base.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.
-
class
ebu_tt_live.documents.base.
DocumentSequence
[source]¶ Bases:
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.
-
add_document
(document)[source]¶ 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.
-
fork
(*args, **kwargs)[source]¶ Create a new stream with modified arguments. :param args: :param kwargs: parameter override to constructor :return: a new documentstream instance
-
ebutt3
Module¶
-
class
ebu_tt_live.documents.ebutt3.
EBUTT3Document
(time_base, sequence_number, sequence_identifier, lang, clock_mode=None, availability_time=None, authors_group_identifier=None)[source]¶ Bases:
ebu_tt_live.documents.ebutt3.TimelineUtilMixin
,ebu_tt_live.documents.base.SubtitleDocument
,ebu_tt_live.documents.ebutt3.EBUTT3ObjectBase
This class wraps the binding object representation of the XML and provides the features the applications in the specification require. e.g:availability time.
-
_availability_time
= None¶
-
_cmp_checks
(other)[source]¶ Extra checks that need to be fulfilled in order for the comparison to make sense. Any custom exceptions thrown here are preserved and propagated in original form. :param other: :return:
-
_computed_begin_time
= None¶
-
_computed_end_time
= None¶
-
_ebutt3_content
= None¶
-
_resolved_begin_time
= None¶
-
_resolved_end_time
= None¶
-
_sequence
= None¶
-
availability_time
¶
-
binding
¶
-
cleanup
()[source]¶ This function is meant to get rid of all the validation added data that may be blocking garbage collection of the objects. :return:
-
clock_mode
¶
-
computed_begin_time
¶
-
computed_end_time
¶
-
content_to_string
(begin=None, end=None)[source]¶ Extract the document textual content between begin/end along with their activation times.
Parameters: - begin – From specified begin time or resolved begin time if begin is not specified.
- end – Up to specified end time or resolved end time if end is not specified.
Returns: String showing the activation and content of the elements.
-
discard_document
(resolved_end_time, verbose=False)[source]¶ This function discards the document by setting a resolved end time before the document begins. :param resolved_end_time:
-
discarded
¶
-
extract_segment
(begin=None, end=None, deconflict_ids=False)[source]¶ Create a valid ebutt3 document subset. As it collects data it will also prefix the ids in the document with the document sequence number so that later merge does not have collision.
Parameters: - begin –
- end –
- deconflict_ids – prevent id clash across documents by prefixing the IDs
Returns: EBUTT3Document
-
lang
¶
-
resolved_begin_time
¶
-
resolved_end_time
¶
-
sequence
¶
-
sequence_identifier
¶
-
sequence_number
¶
-
time_base
¶
-
-
class
ebu_tt_live.documents.ebutt3.
EBUTT3DocumentSequence
(sequence_identifier, reference_clock, lang, verbose=False, authors_group_identifier=None)[source]¶ Bases:
ebu_tt_live.documents.ebutt3.TimelineUtilMixin
,ebu_tt_live.documents.base.CloningDocumentSequence
EBU-TT Live specific document sequence. It maps the documents based on their sequence numbers and timing attributes.
- The sequence object can be used in 2 different modes:
- It can be used to produce a sequence(i.e.: new_document method)
- as well as it is the pivotal point of the consumer use-case when the document timings need to be resolved. (i.e.: add_document method)
The sequence is responsible to keep the documents ordered and filter those documents out, which were eventually overwritten. It ensures that at any given time exactly 0 or 1 document is active (R14).
-
_clock_mode
= None¶
-
_documents
= None¶
-
_insert_document
(document, ends=None)[source]¶ In the end this function adds the document to the sequence registers.
Parameters: - document –
- ends –
Returns:
-
_insert_or_discard
(document)[source]¶ This function does the heavy lifting of timing resolution. It inspects the close vicinity in which the new document is coming by looking at the timeline in both directions.
- Based on that information it can detect 3 different cases:
- out of order delivery of documents in which case it inserts and trims the document,
- sequence override scenario in which case an exception is raised.
- Document discard scenario in which case the document is already overwritten in the sequence so it will not get inserted.
Raises: ValueError, SequenceOverridden, DocumentDiscardedError
-
_lang
= None¶
-
_last_sequence_number
= None¶
-
_override_sequence
(document)[source]¶ This function clears the timeline and the associated documents after the document in the parameter. This happens when a document with a higher sequence number is added preceding some other documents with lower sequence numbers.
Parameters: document – Returns:
-
_reference_clock
= None¶
-
_sequence_identifier
= None¶
-
_time_base
= None¶
-
_verbose
= None¶
-
add_document
(document)[source]¶ 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.
-
create_compatible_document
(*args, **kwargs)[source]¶ This utility function is used by the converter to extract segments and by the new_document function.
Parameters: - args –
- kwargs –
Returns:
-
classmethod
create_from_document
(document, verbose=False, *args, **kwargs)[source]¶ Extract data from document :param document: :param args: :param kwargs: parameter override to constructor :return:
-
discard_before
(document)[source]¶ This function gets rid of old documents we do not wish to keep any longer. :param document: The document up to which we would like to discard things :return:
-
extract_segment
(begin=None, end=None, sequence_number=None, discard=False)[source]¶ Extract the subtitles from the sequence in the given timeframe. The return value is one merged EBUTT3Document
Parameters: - begin –
- end –
Returns: EBUTT3Document
-
fork
(*args, **kwargs)[source]¶ Create a new stream with modified arguments. :param args: :param kwargs: parameter override to constructor :return: a new documentstream instance
-
get_document
(seq_id)[source]¶ Retrieve document by sequence number :param seq_id: :return: a document :raises: KeyError meaning the document is not in the sequence
-
last_sequence_number
¶
-
new_document
(*args, **kwargs)[source]¶ Create a new document with the stream defaults :param args: :param kwargs: parameter override to constructor :return: a new document
-
reference_clock
¶
-
sequence_identifier
¶
-
class
ebu_tt_live.documents.ebutt3.
EBUTT3ObjectBase
[source]¶ Bases:
object
-
message_type_mapping
= {'authorsGroupControlRequest': <class 'ebu_tt_live.documents.ebutt3.EBUTTAuthorsGroupControlRequest'>}¶
-
-
class
ebu_tt_live.documents.ebutt3.
EBUTTAuthorsGroupControlRequest
(sequence_identifier, payload, availability_time=None, sender=None, recipient=None)[source]¶ Bases:
ebu_tt_live.documents.ebutt3.EBUTTLiveMessage
-
message_type_id
= 'authorsGroupControlRequest'¶
-
-
class
ebu_tt_live.documents.ebutt3.
EBUTTLiveMessage
[source]¶ Bases:
ebu_tt_live.documents.ebutt3.EBUTT3ObjectBase
-
_availability_time
= None¶
-
_payload
= None¶
-
_recipient
= None¶
-
_sender
= None¶
-
_sequence_identifier
= None¶
-
availability_time
¶
-
payload
¶
-
recipient
¶
-
sender
¶
-
sequence_identifier
¶
-
-
class
ebu_tt_live.documents.ebutt3.
TimelineUtilMixin
[source]¶ Bases:
object
This mixin is responsible for managing the shared timeline functionality
-
_timeline
= None¶
-
add_to_timeline
(element)[source]¶ The element gets added to the timeline so it would be easier to look up. :param element: :return:
-
lookup_range_on_timeline
(begin=None, end=None)[source]¶ Extract a segment of the timeline and :param begin: :param end: :return: A list of elements in chronological order
-
timeline
¶
-
-
class
ebu_tt_live.documents.ebutt3.
TimingEvent
(element, when)[source]¶ Bases:
object
This class wraps a document and an associated resolved timing event into an object that can be placed on the timeline.
-
_element
= None¶
-
_when
= None¶
-
element
¶
-
when
¶
-
-
class
ebu_tt_live.documents.ebutt3.
TimingEventBegin
(element)[source]¶ Bases:
ebu_tt_live.documents.ebutt3.TimingEvent
Element/document resolved begin time
-
class
ebu_tt_live.documents.ebutt3.
TimingEventEnd
(element)[source]¶ Bases:
ebu_tt_live.documents.ebutt3.TimingEvent
Element/document resolved end time.
ebutt3_segmentation
Module¶
-
class
ebu_tt_live.documents.ebutt3_segmentation.
EBUTT3Segmenter
(document, begin=None, end=None, deconflict_ids=False)[source]¶ Bases:
ebu_tt_live.bindings.pyxb_utils.RecursiveOperation
-
_begin
= None¶
-
_deconflict_ids
= None¶
-
_document
= None¶
-
_end
= None¶
-
_instance_mapping
= None¶
-
_segment
= None¶
-
_semantic_dataset
= None¶
-
begin
¶
-
deconflict_ids
¶
-
document
¶
-
end
¶
-
segment
¶
-
ebutt3_splicer
Module¶
bindings_converters
Module¶
-
class
ebu_tt_live.bindings.converters.ebutt3_ebuttd.
EBUTT3EBUTTDConverter
(media_clock)[source]¶ Bases:
object
-
_dataset_key_for_font_styles
= 'adjusted_sizing_styles'¶
-
_fix_fontsize
(elem, celem, parent, dataset)[source]¶ This function generates styles for the purpose of conversion from c,px values to percentage values. The fontSize attributes were removed in the initial styling copy function so here we generate new ones to serve our purpose best and easiest :param elem: the original instance :param celem: the converted instance :param parent: the parent of the original :param dataset: semantic dataset :return:
-
_font_size_style_template
= 'autogenFontStyle_{}_{}'¶
-
_get_font_size_style
(vertical, dataset, horizontal=None)[source]¶ This function either points us to an already generated version of this style or creates it on demand. :param vertical: :param horizontal: :return:
-
_media_clock
= None¶
-
_semantic_dataset
= None¶
-