How to use the pycaption.DFXPReader function in pycaption

To help you get started, we’ve selected a few pycaption examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbs / pycaption / tests / test_dfxp.py View on Github external
def test_invalid_markup_is_properly_handled(self):
        captions = DFXPReader().read(SAMPLE_DFXP_SYNTAX_ERROR)
        self.assertEqual(2, len(captions.get_captions("en-US")))
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_dfxp_to_webvtt_conversion(self):
        caption_set = DFXPReader().read(SAMPLE_DFXP)
        results = WebVTTWriter().write(caption_set)
        self.assertTrue(isinstance(results, text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_DFXP, results)
github pbs / pycaption / tests / test_dfxp.py View on Github external
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)
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_is_relativized(self):
        # Absolute positioning settings (e.g. px) are converted to percentages
        caption_set = DFXPReader().read(SAMPLE_DFXP_WITH_POSITIONING)
        result = DFXPWriter(
            video_width=VIDEO_WIDTH, video_height=VIDEO_HEIGHT
        ).write(caption_set)
        self.assertEqual(result, SAMPLE_DFXP_WITH_RELATIVIZED_POSITIONING)
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_correct_region_attributes_are_recreated(self):
        caption_set = DFXPReader().read(SAMPLE_DFXP_MULTIPLE_REGIONS_INPUT)
        result = DFXPWriter(
            relativize=False, fit_to_screen=False).write(caption_set)
        self.assertDFXPEquals(result, SAMPLE_DFXP_MULTIPLE_REGIONS_OUTPUT)
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_dont_create_style_tags_with_no_id(self):
        # The 
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_dfxp_to_webvtt_preserves_proper_alignment(self):
        # This failed at one point when the CaptionSet had node breaks with
        # different positioning. It was fixed both at the DFXPReader AND the
        # WebVTTWriter.
        caption_set = DFXPReader().read(DFXP_STYLE_REGION_ALIGN_CONFLICT)
        results = WebVTTWriter().write(caption_set)
        self.assertEqual(
            WEBVTT_FROM_DFXP_WITH_CONFLICTING_ALIGN, results)
github pbs / pycaption / tests / test_dfxp.py View on Github external
def test_caption_length(self):
        captions = DFXPReader().read(SAMPLE_DFXP)
        self.assertEqual(7, len(captions.get_captions("en-US")))
github pbs / pycaption / tests / test_dfxp_conversion.py View on Github external
def test_dfxp_with_inline_style_to_webvtt_conversion(self):
        caption_set = DFXPReader().read(SAMPLE_DFXP_WITH_INLINE_STYLE)
        results = WebVTTWriter().write(caption_set)
        self.assertTrue(isinstance(results, text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_DFXP_WITH_STYLE, results)