How to use pycaption - 10 common examples

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_geometry.py View on Github external
def test_point_is_relative(self):
        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)

        point_abs = Point(size_px, size_px2)
        point_mix = Point(size_percent, size_px)
        point_rel = Point(size_percent, size_percent2)

        self.assertFalse(point_abs.is_relative())
        self.assertFalse(point_mix.is_relative())
        self.assertTrue(point_rel.is_relative())
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_stretch_is_relative(self):
        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)

        stretch_abs = Stretch(size_px, size_px2)
        stretch_mix = Stretch(size_percent, size_px)
        stretch_rel = Stretch(size_percent, size_percent2)

        self.assertFalse(stretch_abs.is_relative())
        self.assertFalse(stretch_mix.is_relative())
        self.assertTrue(stretch_rel.is_relative())
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_layout_is_relative(self):
        empty_layout = Layout()

        self.assertTrue(empty_layout.is_relative())

        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)

        point_abs = Point(size_px, size_px2)
        point_rel = Point(size_percent, size_percent2)

        stretch_abs = Stretch(size_px, size_px2)
        stretch_rel = Stretch(size_percent, size_percent2)

        layout_abs = Layout(
            origin=point_abs,
            extent=stretch_abs,
            padding=None
        )
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_size_is_valid(self):
        with self.assertRaises(TypeError):
            Size()

        with self.assertRaises(ValueError):
            Size(None, None)
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_layout_is_relative(self):
        empty_layout = Layout()

        self.assertTrue(empty_layout.is_relative())

        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)

        point_abs = Point(size_px, size_px2)
        point_rel = Point(size_percent, size_percent2)

        stretch_abs = Stretch(size_px, size_px2)
        stretch_rel = Stretch(size_percent, size_percent2)

        layout_abs = Layout(
            origin=point_abs,
            extent=stretch_abs,
            padding=None
        )
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_padding_is_relative(self):
        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)
        size_px3 = Size(30, UnitEnum.PIXEL)
        size_px4 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)
        size_percent3 = Size(30, UnitEnum.PERCENT)
        size_percent4 = Size(30, UnitEnum.PERCENT)

        padding_abs = Padding(size_px, size_px2, size_px3, size_px4)
        padding_mix = Padding(size_px, size_px2, size_px3, size_percent)
        padding_rel = Padding(
            size_percent, size_percent2, size_percent3, size_percent4)

        self.assertFalse(padding_abs.is_relative())
        self.assertFalse(padding_mix.is_relative())
        self.assertTrue(padding_rel.is_relative())
github pbs / pycaption / tests / test_geometry.py View on Github external
def test_point_is_relative(self):
        size_px = Size(30, UnitEnum.PIXEL)
        size_px2 = Size(30, UnitEnum.PIXEL)

        size_percent = Size(30, UnitEnum.PERCENT)
        size_percent2 = Size(30, UnitEnum.PERCENT)

        point_abs = Point(size_px, size_px2)
        point_mix = Point(size_percent, size_px)
        point_rel = Point(size_percent, size_percent2)

        self.assertFalse(point_abs.is_relative())
        self.assertFalse(point_mix.is_relative())
        self.assertTrue(point_rel.is_relative())
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.py View on Github external
def test_caption_error_for_invalid_or_unsupported_positioning_units(self):
        invalid_dfxp = (
            SAMPLE_DFXP_INVALID_POSITIONING_VALUE_TEMPLATE
            .format(origin="6foo 7bar")
        )
        self.assertRaises(
            CaptionReadSyntaxError, DFXPReader().read,
            invalid_dfxp
        )
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)