def test_ericsson_1(self): xml_file = self._load_asset('converter_ericsson1.xml') self._media_clock.adjust_time(timedelta(), ebuttdt.LimitedClockTimingType('12:11:50.000').timedelta) document = EBUTT3Document.create_from_xml(xml_file) cdoc = ebutt3_to_ebuttd(document, self._media_clock) print cdoc.get_xml()
def _create_document(self, sequence_number, begin, end): doc = EBUTT3Document(time_base='clock', clock_mode='local', lang='en-gb', sequence_identifier='ConsumerTest', sequence_number=sequence_number) doc.set_begin(self._get_timing_type(timedelta(seconds=begin))) doc.set_end(self._get_timing_type(timedelta(seconds=end))) doc.availability_time = timedelta() return doc
def test_one(self): document = EBUTT3Document.create_from_raw_binding(binding=self.tt) document.validate() cdoc = self.replaceStylesAndRegions(document, self.test_old_ids, self.test_new_ids) cdoc.proceed() document.validate() print document.get_xml()
def test_simple(self): div = div_type( p_type(span_type('Here we are', br_type(), 'in 2 lines.'), id='ID001', begin=ebuttdt.FullClockTimingType(timedelta(seconds=1)), end=ebuttdt.FullClockTimingType(timedelta(seconds=3)))) document = EBUTT3Document(time_base='media', lang='en-GB', sequence_identifier='TestSeq1', sequence_number=1) document.add_div(div) document.validate() ebutt3_to_ebuttd(document, self._media_clock)
def main(): create_loggers(logging.INFO) log.info("Dummy XML Encoder") tt = bindings.tt( sequenceIdentifier="testSequence001", sequenceNumber="1", timeBase="clock", extent="800px 600px", clockMode="local", lang="en-GB", ) head_elem = bindings.head_type( metadata.headMetadata_type(metadata.documentMetadata()), bindings.styling( bindings.style_type(id="style1", fontSize="12px"), bindings.style_type(id="style2", fontSize="15px"), bindings.style_type(id="style3", color="red", fontSize="12px"), bindings.style_type(id="style4", backgroundColor="blue"), ), bindings.layout( bindings.region_type(id="region1", origin="200px 450px", extent="300px 150px", style=["style3"]) ), ) body_elem = bindings.body_type( bindings.div_type( bindings.p_type( bindings.span_type( "Some example text...", begin=datatypes.LimitedClockTimingType(timedelta(seconds=1)), end=datatypes.LimitedClockTimingType(timedelta(seconds=2)), style=["style4"], id="span1", ), bindings.br_type(), bindings.span_type( "And another line", begin=datatypes.LimitedClockTimingType(timedelta(seconds=3)), end=datatypes.LimitedClockTimingType(timedelta(seconds=4)), id="span2", ), id="ID005", ), style=["style1"], region="region1", ), begin=datatypes.LimitedClockTimingType(timedelta(seconds=0.5)), dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)), style=["style2"], ) tt.head = head_elem tt.body = body_elem document = EBUTT3Document.create_from_raw_binding(tt) document.validate() print(document.get_xml()) log.info("XML output printed")
def main(): create_loggers(logging.INFO) log.info('Dummy XML Encoder') tt = bindings.tt(sequenceIdentifier='testSequence001', sequenceNumber='1', timeBase='clock', extent='800px 600px', clockMode='local', lang='en-GB') head_elem = bindings.head_type( metadata.headMetadata_type(metadata.documentMetadata()), bindings.styling( bindings.style_type(id='style1', fontSize='12px'), bindings.style_type(id='style2', fontSize='15px'), bindings.style_type(id='style3', color='red', fontSize='12px'), bindings.style_type(id='style4', backgroundColor='blue')), bindings.layout( bindings.region_type(id='region1', origin='200px 450px', extent='300px 150px', style=['style3']))) body_elem = bindings.body_type( bindings.div_type(bindings.p_type( bindings.span_type( 'Some example text...', begin=datatypes.LimitedClockTimingType(timedelta(seconds=1)), end=datatypes.LimitedClockTimingType(timedelta(seconds=2)), style=['style4'], id='span1'), bindings.br_type(), bindings.span_type( 'And another line', begin=datatypes.LimitedClockTimingType(timedelta(seconds=3)), end=datatypes.LimitedClockTimingType(timedelta(seconds=4)), id='span2'), id='ID005', ), style=['style1'], region='region1'), begin=datatypes.LimitedClockTimingType(timedelta(seconds=.5)), dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)), style=['style2']) applied_proc1 = metadata.appliedProcessing_type( process='Creation', generatedBy='ebu_dummy_encoder', appliedDateTime=datetime.now()) applied_proc2 = metadata.appliedProcessing_type( process='Validation', generatedBy='ebu_dummy_encoder', appliedDateTime=datetime.now()) head_elem.metadata.documentMetadata.appliedProcessing.append(applied_proc1) head_elem.metadata.documentMetadata.appliedProcessing.append(applied_proc2) tt.head = head_elem tt.body = body_elem document = EBUTT3Document.create_from_raw_binding(tt) document.validate() print(document.get_xml()) log.info('XML output printed')
def test_trimmed_1(self): tt = bindings.tt( sequenceIdentifier='testSequence001', sequenceNumber='1', timeBase='clock', extent='800px 600px', clockMode='local', lang='en-GB' ) head_elem = bindings.head_type( metadata.headMetadata_type( metadata.documentMetadata() ), bindings.styling( bindings.style_type( id='style1', fontSize='12px' ), bindings.style_type( id='style2', fontSize='15px' ), bindings.style_type( id='style3', color='red', fontSize='12px' ), bindings.style_type( id='style4', backgroundColor='blue' ) ), bindings.layout( bindings.region_type( id='region1', origin='200px 450px', extent='300px 150px', style=['style3'] ) ) ) body_elem = bindings.body_type( bindings.div_type( bindings.p_type( bindings.span_type( 'Some example text...', begin=datatypes.LimitedClockTimingType(timedelta(seconds=1)), end=datatypes.LimitedClockTimingType(timedelta(seconds=2)), style=['style4'], id='span1' ), bindings.br_type(), bindings.span_type( 'And another line', begin=datatypes.LimitedClockTimingType(timedelta(seconds=3)), end=datatypes.LimitedClockTimingType(timedelta(seconds=4)), id='span2' ), id='ID005' ), style=['style1'], region='region1' ), begin=datatypes.LimitedClockTimingType(timedelta(seconds=.5)), dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)), style=['style2'] ) tt.head = head_elem tt.body = body_elem document = EBUTT3Document.create_from_raw_binding(binding=tt) document.validate() self.assertIsInstance(document.get_element_by_id('region1'), bindings.region_type) self.assertIsInstance(document.get_element_by_id('style1'), bindings.style_type) self.assertIsInstance(document.get_element_by_id('style2'), bindings.style_type) self.assertIsInstance(document.get_element_by_id('style3'), bindings.style_type) self.assertIsInstance(document.get_element_by_id('style4'), bindings.style_type) self.assertIsInstance(document.get_element_by_id('ID005'), bindings.p_type) self.assertIsInstance(document.get_element_by_id('span1'), bindings.span_type) self.assertIsInstance(document.get_element_by_id('span2'), bindings.span_type) cdoc = document.extract_segment(deconflict_ids=True, begin=timedelta(seconds=2.5)) self.assertIsInstance(cdoc.get_element_by_id('SEQ1.region1'), bindings.region_type) self.assertIsInstance(cdoc.get_element_by_id('SEQ1.style1'), bindings.style_type) self.assertIsInstance(cdoc.get_element_by_id('SEQ1.style2'), bindings.style_type) self.assertIsInstance(cdoc.get_element_by_id('SEQ1.style3'), bindings.style_type) self.assertRaises(LookupError, cdoc.get_element_by_id, 'SEQ1.style4') self.assertIsInstance(cdoc.get_element_by_id('SEQ1.ID005'), bindings.p_type) self.assertRaises(LookupError, cdoc.get_element_by_id, 'SEQ1.span1') self.assertIsInstance(cdoc.get_element_by_id('SEQ1.span2'), bindings.span_type)
def test_simple(self): tt = bindings.tt( sequenceIdentifier='testSequence001', sequenceNumber='1', timeBase='clock', extent='800px 600px', clockMode='local', lang='en-GB' ) head_elem = bindings.head_type( metadata.headMetadata_type( metadata.documentMetadata() ), bindings.styling( bindings.style_type( id='style1', fontSize='12px' ), bindings.style_type( id='style2', fontSize='15px' ), bindings.style_type( id='style3', color='red', fontSize='12px' ) ), bindings.layout( bindings.region_type( id='region1', origin='200px 450px', extent='300px 150px', style=['style3'] ) ) ) body_elem = bindings.body_type( bindings.div_type( bindings.p_type( bindings.span_type( 'Some example text...' ), bindings.br_type(), bindings.span_type( 'And another line' ), id='ID005', begin=datatypes.LimitedClockTimingType(timedelta(seconds=.5)), end=datatypes.LimitedClockTimingType(timedelta(seconds=3.42)), ), style=['style1'], region='region1' ), begin=datatypes.LimitedClockTimingType(timedelta(seconds=.5)), dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)), style=['style2'] ) tt.head = head_elem tt.body = body_elem document = EBUTT3Document.create_from_raw_binding(binding=tt) document.validate() document.extract_segment(deconflict_ids=True)