pycaption 2.3.4__tar.gz → 2.3.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycaption-2.3.4/pycaption.egg-info → pycaption-2.3.5}/PKG-INFO +1 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/constants.py +1 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/writer.py +3 -18
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/geometry.py +0 -9
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/writer.py +0 -6
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/specialized_collections.py +0 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/writer.py +0 -3
- {pycaption-2.3.4 → pycaption-2.3.5/pycaption.egg-info}/PKG-INFO +1 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/setup.py +1 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/webvtt.py +1 -1
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_sami_conversion.py +4 -4
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_conversion.py +4 -8
- {pycaption-2.3.4 → pycaption-2.3.5}/LICENSE +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/MANIFEST.in +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/README.rst +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/base.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/extras.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/reader.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/exceptions.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/microdvd.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/constants.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/parser.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/reader.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/constants.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/reader.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/state_machines.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/translator.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/writer.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/srt.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/transcript.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/utils.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/constants.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/reader.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/SOURCES.txt +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/dependency_links.txt +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/requires.txt +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/top_level.txt +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/setup.cfg +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/conftest.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/__init__.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/dfxp.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/microdvd.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/sami.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/scc.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/srt.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/translated_scc.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/mixins.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_base.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_bytes_input.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp_conversion.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp_extras.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_double_encoding.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_functions.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_geometry.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_microdvd.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_microdvd_conversion.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_sami.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_translator.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_writer.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_srt.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_srt_conversion.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_webvtt.py +0 -0
- {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_webvtt_conversion.py +0 -0
|
@@ -30,7 +30,7 @@ DFXP_DEFAULT_REGION = Layout(
|
|
|
30
30
|
alignment=Alignment(HorizontalAlignmentEnum.START, VerticalAlignmentEnum.BOTTOM)
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
# Writer fallback alignment used when layout is None
|
|
33
|
+
# Writer fallback alignment used when layout is None.
|
|
34
34
|
DFXP_WRITER_FALLBACK_ALIGNMENT = Alignment(
|
|
35
35
|
HorizontalAlignmentEnum.CENTER, VerticalAlignmentEnum.BOTTOM
|
|
36
36
|
)
|
|
@@ -294,8 +294,7 @@ class RegionCreator:
|
|
|
294
294
|
def _collect_unique_regions(caption_set, ignore_region):
|
|
295
295
|
"""Collect all unique Layout objects from the caption set.
|
|
296
296
|
|
|
297
|
-
Excludes None
|
|
298
|
-
SCC positional layouts (which map to the default center region).
|
|
297
|
+
Excludes None and ignore_region (typically the default region).
|
|
299
298
|
|
|
300
299
|
:type caption_set: CaptionSet
|
|
301
300
|
:param ignore_region: a Layout to exclude from the result
|
|
@@ -315,9 +314,6 @@ class RegionCreator:
|
|
|
315
314
|
|
|
316
315
|
unique_regions.pop(None, None)
|
|
317
316
|
unique_regions.pop(ignore_region, None)
|
|
318
|
-
for layout in list(unique_regions):
|
|
319
|
-
if layout and layout.is_positional_anchor:
|
|
320
|
-
unique_regions.pop(layout)
|
|
321
317
|
return unique_regions
|
|
322
318
|
|
|
323
319
|
def _create_unique_regions(self, unique_layouts, dfxp, id_factory):
|
|
@@ -432,9 +428,6 @@ class RegionCreator:
|
|
|
432
428
|
if not layout_info:
|
|
433
429
|
layout_info = caption_set.layout_info
|
|
434
430
|
|
|
435
|
-
if layout_info and layout_info.is_positional_anchor:
|
|
436
|
-
layout_info = None
|
|
437
|
-
|
|
438
431
|
region_id = self._region_map.get(layout_info)
|
|
439
432
|
if not region_id:
|
|
440
433
|
region_id = DFXP_DEFAULT_REGION_ID
|
|
@@ -506,8 +499,8 @@ def _convert_layout_to_attributes(layout, fallback_alignment=None):
|
|
|
506
499
|
Maps origin, extent, padding, alignment, and writing_direction to their
|
|
507
500
|
tts: namespace equivalents.
|
|
508
501
|
|
|
509
|
-
When layout is None
|
|
510
|
-
|
|
502
|
+
When layout is None, uses fallback_alignment if provided
|
|
503
|
+
(per RP 2052-10 center promotion).
|
|
511
504
|
|
|
512
505
|
:type layout: Layout | None
|
|
513
506
|
:param fallback_alignment: Alignment to use when the layout lacks one.
|
|
@@ -521,14 +514,6 @@ def _convert_layout_to_attributes(layout, fallback_alignment=None):
|
|
|
521
514
|
return _create_external_alignment(fallback_alignment)
|
|
522
515
|
return result
|
|
523
516
|
|
|
524
|
-
if layout.is_positional_anchor:
|
|
525
|
-
if fallback_alignment:
|
|
526
|
-
result.update(_create_external_alignment(fallback_alignment))
|
|
527
|
-
writing_mode = _WRITING_DIRECTION_TO_DFXP.get(layout.writing_direction)
|
|
528
|
-
if writing_mode:
|
|
529
|
-
result["tts:writingMode"] = writing_mode
|
|
530
|
-
return result
|
|
531
|
-
|
|
532
517
|
if layout.origin:
|
|
533
518
|
result["tts:origin"] = layout.origin.to_xml_attribute()
|
|
534
519
|
|
|
@@ -597,7 +597,6 @@ class Layout:
|
|
|
597
597
|
alignment=None,
|
|
598
598
|
webvtt_positioning=None,
|
|
599
599
|
writing_direction=None,
|
|
600
|
-
is_positional_anchor=False,
|
|
601
600
|
inherit_from=None,
|
|
602
601
|
):
|
|
603
602
|
"""
|
|
@@ -623,11 +622,6 @@ class Layout:
|
|
|
623
622
|
:type writing_direction: WritingDirectionEnum
|
|
624
623
|
:param writing_direction: WebVTT vertical writing direction (rl or lr).
|
|
625
624
|
|
|
626
|
-
:type is_positional_anchor: bool
|
|
627
|
-
:param is_positional_anchor: True when the origin/alignment describe a
|
|
628
|
-
coordinate-system anchor point (e.g. SCC row/col positioning) rather
|
|
629
|
-
than visual text alignment.
|
|
630
|
-
|
|
631
625
|
:type inherit_from: Layout
|
|
632
626
|
:param inherit_from: A Layout with the positioning parameters to be
|
|
633
627
|
used if not specified by the positioning arguments,
|
|
@@ -639,7 +633,6 @@ class Layout:
|
|
|
639
633
|
self.alignment = alignment
|
|
640
634
|
self.webvtt_positioning = webvtt_positioning
|
|
641
635
|
self.writing_direction = writing_direction
|
|
642
|
-
self.is_positional_anchor = is_positional_anchor
|
|
643
636
|
|
|
644
637
|
if inherit_from:
|
|
645
638
|
for attr_name in [
|
|
@@ -716,7 +709,6 @@ class Layout:
|
|
|
716
709
|
params = {
|
|
717
710
|
"alignment": self.alignment,
|
|
718
711
|
"writing_direction": self.writing_direction,
|
|
719
|
-
"is_positional_anchor": self.is_positional_anchor,
|
|
720
712
|
}
|
|
721
713
|
for attr_name in ["origin", "extent", "padding"]:
|
|
722
714
|
attr = getattr(self, attr_name)
|
|
@@ -751,7 +743,6 @@ class Layout:
|
|
|
751
743
|
padding=self.padding,
|
|
752
744
|
alignment=self.alignment,
|
|
753
745
|
writing_direction=self.writing_direction,
|
|
754
|
-
is_positional_anchor=self.is_positional_anchor,
|
|
755
746
|
)
|
|
756
747
|
|
|
757
748
|
def _corrected_extent(self, diff_horizontal, diff_vertical):
|
|
@@ -131,9 +131,6 @@ class SAMIWriter(BaseWriter):
|
|
|
131
131
|
if not layout_info:
|
|
132
132
|
return
|
|
133
133
|
|
|
134
|
-
if layout_info.is_positional_anchor:
|
|
135
|
-
return
|
|
136
|
-
|
|
137
134
|
if layout_info.origin:
|
|
138
135
|
if layout_info.origin.x:
|
|
139
136
|
parts.append(f"margin-left:{layout_info.origin.x};")
|
|
@@ -152,9 +149,6 @@ class SAMIWriter(BaseWriter):
|
|
|
152
149
|
if not layout_info:
|
|
153
150
|
return "center" if self._promote_center else None
|
|
154
151
|
|
|
155
|
-
if layout_info.is_positional_anchor:
|
|
156
|
-
return "center" if self._promote_center else None
|
|
157
|
-
|
|
158
152
|
if not layout_info.alignment:
|
|
159
153
|
return "center" if self._promote_center else None
|
|
160
154
|
|
|
@@ -211,10 +211,10 @@ class TestWebVTTtoSAMIStyles(SAMITestingMixIn):
|
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
class TestSCCtoSAMI(SAMITestingMixIn):
|
|
214
|
-
def
|
|
214
|
+
def test_scc_to_sami_preserves_positioning(self, sample_scc_pop_on):
|
|
215
215
|
caption_set = SCCReader().read(sample_scc_pop_on)
|
|
216
216
|
result = SAMIWriter().write(caption_set)
|
|
217
217
|
|
|
218
|
-
assert "text-align:
|
|
219
|
-
assert "margin-left"
|
|
220
|
-
assert "margin-top"
|
|
218
|
+
assert "text-align:left;" in result
|
|
219
|
+
assert "margin-left:" in result
|
|
220
|
+
assert "margin-top:" in result
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
2
|
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
3
|
from pycaption import (
|
|
6
4
|
DFXPWriter,
|
|
7
5
|
SCCReader,
|
|
@@ -42,9 +40,8 @@ class TestSCCtoDFXP:
|
|
|
42
40
|
caption_set = SCCReader().read(sample_scc_multiple_positioning)
|
|
43
41
|
dfxp = DFXPWriter(relativize=False, fit_to_screen=False).write(caption_set)
|
|
44
42
|
|
|
45
|
-
assert 'tts:textAlign="
|
|
46
|
-
assert
|
|
47
|
-
assert "tts:origin" not in dfxp
|
|
43
|
+
assert 'tts:textAlign="left"' in dfxp
|
|
44
|
+
assert "tts:origin" in dfxp
|
|
48
45
|
assert "abab" in dfxp
|
|
49
46
|
assert "ghgh" in dfxp
|
|
50
47
|
|
|
@@ -58,8 +55,7 @@ class TestSCCtoDFXP:
|
|
|
58
55
|
|
|
59
56
|
dfxp = DFXPWriter().write(caption_set)
|
|
60
57
|
|
|
61
|
-
assert 'tts:textAlign="
|
|
62
|
-
assert 'tts:textAlign="left"' not in dfxp
|
|
58
|
+
assert 'tts:textAlign="left"' in dfxp
|
|
63
59
|
assert 'tts:fontStyle="italic"' in dfxp
|
|
64
60
|
from bs4 import BeautifulSoup
|
|
65
61
|
|
|
@@ -72,7 +68,7 @@ class TestSCCtoDFXP:
|
|
|
72
68
|
|
|
73
69
|
dfxp = DFXPWriter().write(caption_set)
|
|
74
70
|
|
|
75
|
-
assert 'tts:textAlign="
|
|
71
|
+
assert 'tts:textAlign="left"' in dfxp
|
|
76
72
|
assert "&" in dfxp
|
|
77
73
|
from bs4 import BeautifulSoup
|
|
78
74
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|