當前位置: 首頁>>代碼示例>>Python>>正文


Python pycaption.DFXPReader類代碼示例

本文整理匯總了Python中pycaption.DFXPReader的典型用法代碼示例。如果您正苦於以下問題:Python DFXPReader類的具體用法?Python DFXPReader怎麽用?Python DFXPReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DFXPReader類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_individual_timings_of_captions_with_matching_timespec_are_kept

 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)
開發者ID:jpenney,項目名稱:pycaption,代碼行數:8,代碼來源:test_dfxp.py

示例2: test_merge_concurrent_captions

    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)
開發者ID:MagikVision,項目名稱:pycaption,代碼行數:8,代碼來源:test_functions.py

示例3: test_properly_converts_timing

 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)
開發者ID:MagikVision,項目名稱:pycaption,代碼行數:8,代碼來源:test_dfxp.py

示例4: test_proper_xml_entity_escaping

 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"&lt;&lt; \"Andy's Café &amp; Restaurant\" this way",
         result
     )
開發者ID:MagikVision,項目名稱:pycaption,代碼行數:10,代碼來源:test_dfxp_conversion.py

示例5: test_individual_layouts_of_captions_with_matching_timespec_are_kept

    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)
開發者ID:jpenney,項目名稱:pycaption,代碼行數:12,代碼來源:test_dfxp.py

示例6: test_individual_texts_of_captions_with_matching_timespec_are_kept

    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)
開發者ID:jpenney,項目名稱:pycaption,代碼行數:12,代碼來源:test_dfxp.py

示例7: test_individual_layouts_of_captions_with_matching_timespec_are_kept

    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)
開發者ID:mwx-limited,項目名稱:pycaption,代碼行數:12,代碼來源:test_dfxp.py

示例8: test_offset_time

 def test_offset_time(self):
     reader = DFXPReader()
     self.assertEqual(1, reader._translate_time("0.001ms"))
     self.assertEqual(2000, reader._translate_time("2ms"))
     self.assertEqual(1000000, reader._translate_time("1s"))
     self.assertEqual(1234567, reader._translate_time("1.234567s"))
     self.assertEqual(180000000, reader._translate_time("3m"))
     self.assertEqual(14400000000, reader._translate_time("4h"))
     # Tick values are not supported
     self.assertRaises(
         InvalidInputError, reader._translate_time, "2.3t")
開發者ID:mwx-limited,項目名稱:pycaption,代碼行數:11,代碼來源:test_dfxp.py

示例9: test_invalid_markup_is_properly_handled

 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")))
開發者ID:jpenney,項目名稱:pycaption,代碼行數:3,代碼來源:test_dfxp.py

示例10: test_proper_timestamps

    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)
開發者ID:jpenney,項目名稱:pycaption,代碼行數:6,代碼來源:test_dfxp.py

示例11: test_caption_length

 def test_caption_length(self):
     captions = DFXPReader().read(SAMPLE_DFXP.decode(u'utf-8'))
     self.assertEquals(8, len(captions.get_captions(u"en-US")))
開發者ID:jpenney,項目名稱:pycaption,代碼行數:3,代碼來源:test_dfxp.py

示例12: test_caption_length

 def test_caption_length(self):
     captions = DFXPReader().read(SAMPLE_DFXP)
     self.assertEquals(7, len(captions.get_captions(u"en-US")))
開發者ID:MagikVision,項目名稱:pycaption,代碼行數:3,代碼來源:test_dfxp.py

示例13: test_empty_cue

 def test_empty_cue(self):
     caption_set = DFXPReader().read(
         SAMPLE_DFXP_EMPTY_CUE)
     caps = caption_set.get_captions('en-US')
     self.assertEquals(caps[1], [])
開發者ID:clovis818,項目名稱:pycaption,代碼行數:5,代碼來源:test_dfxp.py

示例14: test_proper_pcc_format

    def test_proper_pcc_format(self):
        captions = DFXPReader().read(SAMPLE_DFXP)

        self.assertEquals(set(["captions", "styles"]), set(captions.keys()))
        self.assertEquals(7, len(captions["captions"]["en-US"]))
開發者ID:DramaFever,項目名稱:pycaption,代碼行數:5,代碼來源:test_dfxp.py


注:本文中的pycaption.DFXPReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。