本文整理匯總了Python中pycaption.DFXPReader.get_captions方法的典型用法代碼示例。如果您正苦於以下問題:Python DFXPReader.get_captions方法的具體用法?Python DFXPReader.get_captions怎麽用?Python DFXPReader.get_captions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pycaption.DFXPReader
的用法示例。
在下文中一共展示了DFXPReader.get_captions方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_merge_concurrent_captions
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_merge_concurrent_captions(self):
caption_set = DFXPReader().read(DFXP_WITH_CONCURRENT_CAPTIONS)
captions = caption_set.get_captions('en-US')
self.assertEqual(len(captions), 5)
caption_set = merge_concurrent_captions(caption_set)
captions = caption_set.get_captions('en-US')
self.assertEqual(len(captions), 3)
示例2: test_individual_timings_of_captions_with_matching_timespec_are_kept
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_individual_timings_of_captions_with_matching_timespec_are_kept(self): # noqa
captionset = DFXPReader().read(
SAMPLE_DFXP_MULTIPLE_CAPTIONS_WITH_THE_SAME_TIMING
)
expected_timings = [(9209000, 12312000)] * 3
actual_timings = [(c_.start, c_.end) for c_ in
captionset.get_captions('en-US')]
self.assertEqual(expected_timings, actual_timings)
示例3: test_properly_converts_timing
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_properly_converts_timing(self):
caption_set = DFXPReader().read(
DFXP_WITH_ALTERNATIVE_TIMING_FORMATS)
caps = caption_set.get_captions('en-US')
self.assertEqual(caps[0].start, 1900000)
self.assertEqual(caps[0].end, 3050000)
self.assertEqual(caps[1].start, 4000000)
self.assertEqual(caps[1].end, 5200000)
示例4: test_proper_xml_entity_escaping
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_proper_xml_entity_escaping(self):
caption_set = DFXPReader().read(DFXP_WITH_ESCAPED_APOSTROPHE)
cue_text = caption_set.get_captions(u'en-US')[0].nodes[0].content
self.assertEqual(
cue_text, u"<< \"Andy's Caf\xe9 & Restaurant\" this way")
result = DFXPWriter().write(caption_set)
self.assertIn(
u"<< \"Andy's Café & Restaurant\" this way",
result
)
示例5: test_individual_layouts_of_captions_with_matching_timespec_are_kept
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_individual_layouts_of_captions_with_matching_timespec_are_kept(self): # noqa
captionset = DFXPReader().read(
SAMPLE_DFXP_MULTIPLE_CAPTIONS_WITH_THE_SAME_TIMING
)
expected_layouts = [
(((10, u'%'), (10, u'%')), None, None, (u'center', u'bottom')),
(((40, u'%'), (40, u'%')), None, None, (u'center', u'bottom')),
(((10, u'%'), (70, u'%')), None, None, (u'center', u'bottom'))]
actual_layouts = [c_.layout_info.serialized() for c_ in
captionset.get_captions('en-US')]
self.assertEqual(expected_layouts, actual_layouts)
示例6: test_individual_texts_of_captions_with_matching_timespec_are_kept
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_individual_texts_of_captions_with_matching_timespec_are_kept(self): # noqa
captionset = DFXPReader().read(
SAMPLE_DFXP_MULTIPLE_CAPTIONS_WITH_THE_SAME_TIMING
)
expected_texts = [u'Some text here',
u'Some text there',
u'Caption texts are everywhere!']
actual_texts = [c_.nodes[0].content for c_ in
captionset.get_captions("en-US")]
self.assertEqual(expected_texts, actual_texts)
示例7: test_individual_layouts_of_captions_with_matching_timespec_are_kept
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_individual_layouts_of_captions_with_matching_timespec_are_kept(self): # noqa
captionset = DFXPReader().read(
SAMPLE_DFXP_MULTIPLE_CAPTIONS_WITH_THE_SAME_TIMING
)
expected_layouts = [
(((10, UnitEnum.PERCENT), (10, UnitEnum.PERCENT)), None, None, (HorizontalAlignmentEnum.CENTER, VerticalAlignmentEnum.BOTTOM)),
(((40, UnitEnum.PERCENT), (40, UnitEnum.PERCENT)), None, None, (HorizontalAlignmentEnum.CENTER, VerticalAlignmentEnum.BOTTOM)),
(((10, UnitEnum.PERCENT), (70, UnitEnum.PERCENT)), None, None, (HorizontalAlignmentEnum.CENTER, VerticalAlignmentEnum.BOTTOM))]
actual_layouts = [c_.layout_info.serialized() for c_ in
captionset.get_captions('en-US')]
self.assertEqual(expected_layouts, actual_layouts)
示例8: test_invalid_markup_is_properly_handled
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_invalid_markup_is_properly_handled(self):
captions = DFXPReader().read(SAMPLE_DFXP_SYNTAX_ERROR.decode(u'utf-8'))
self.assertEquals(2, len(captions.get_captions(u"en-US")))
示例9: test_proper_timestamps
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_proper_timestamps(self):
captions = DFXPReader().read(SAMPLE_DFXP.decode(u'utf-8'))
paragraph = captions.get_captions(u"en-US")[2]
self.assertEquals(17000000, paragraph.start)
self.assertEquals(18752000, paragraph.end)
示例10: test_caption_length
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_caption_length(self):
captions = DFXPReader().read(SAMPLE_DFXP.decode(u'utf-8'))
self.assertEquals(8, len(captions.get_captions(u"en-US")))
示例11: test_caption_length
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_caption_length(self):
captions = DFXPReader().read(SAMPLE_DFXP)
self.assertEquals(7, len(captions.get_captions(u"en-US")))
示例12: test_empty_cue
# 需要導入模塊: from pycaption import DFXPReader [as 別名]
# 或者: from pycaption.DFXPReader import get_captions [as 別名]
def test_empty_cue(self):
caption_set = DFXPReader().read(
SAMPLE_DFXP_EMPTY_CUE)
caps = caption_set.get_captions('en-US')
self.assertEquals(caps[1], [])