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.
Files changed (71) hide show
  1. {pycaption-2.3.4/pycaption.egg-info → pycaption-2.3.5}/PKG-INFO +1 -1
  2. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/constants.py +1 -1
  3. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/writer.py +3 -18
  4. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/geometry.py +0 -9
  5. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/writer.py +0 -6
  6. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/specialized_collections.py +0 -1
  7. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/writer.py +0 -3
  8. {pycaption-2.3.4 → pycaption-2.3.5/pycaption.egg-info}/PKG-INFO +1 -1
  9. {pycaption-2.3.4 → pycaption-2.3.5}/setup.py +1 -1
  10. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/webvtt.py +1 -1
  11. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_sami_conversion.py +4 -4
  12. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_conversion.py +4 -8
  13. {pycaption-2.3.4 → pycaption-2.3.5}/LICENSE +0 -0
  14. {pycaption-2.3.4 → pycaption-2.3.5}/MANIFEST.in +0 -0
  15. {pycaption-2.3.4 → pycaption-2.3.5}/README.rst +0 -0
  16. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/__init__.py +0 -0
  17. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/base.py +0 -0
  18. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/__init__.py +0 -0
  19. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/extras.py +0 -0
  20. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/dfxp/reader.py +0 -0
  21. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/exceptions.py +0 -0
  22. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/microdvd.py +0 -0
  23. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/__init__.py +0 -0
  24. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/constants.py +0 -0
  25. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/parser.py +0 -0
  26. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/sami/reader.py +0 -0
  27. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/__init__.py +0 -0
  28. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/constants.py +0 -0
  29. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/reader.py +0 -0
  30. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/state_machines.py +0 -0
  31. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/translator.py +0 -0
  32. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/scc/writer.py +0 -0
  33. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/srt.py +0 -0
  34. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/transcript.py +0 -0
  35. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/utils.py +0 -0
  36. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/__init__.py +0 -0
  37. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/constants.py +0 -0
  38. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption/webvtt/reader.py +0 -0
  39. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/SOURCES.txt +0 -0
  40. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/dependency_links.txt +0 -0
  41. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/requires.txt +0 -0
  42. {pycaption-2.3.4 → pycaption-2.3.5}/pycaption.egg-info/top_level.txt +0 -0
  43. {pycaption-2.3.4 → pycaption-2.3.5}/setup.cfg +0 -0
  44. {pycaption-2.3.4 → pycaption-2.3.5}/tests/__init__.py +0 -0
  45. {pycaption-2.3.4 → pycaption-2.3.5}/tests/conftest.py +0 -0
  46. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/__init__.py +0 -0
  47. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/dfxp.py +0 -0
  48. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/microdvd.py +0 -0
  49. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/sami.py +0 -0
  50. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/scc.py +0 -0
  51. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/srt.py +0 -0
  52. {pycaption-2.3.4 → pycaption-2.3.5}/tests/fixtures/translated_scc.py +0 -0
  53. {pycaption-2.3.4 → pycaption-2.3.5}/tests/mixins.py +0 -0
  54. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_base.py +0 -0
  55. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_bytes_input.py +0 -0
  56. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp.py +0 -0
  57. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp_conversion.py +0 -0
  58. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_dfxp_extras.py +0 -0
  59. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_double_encoding.py +0 -0
  60. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_functions.py +0 -0
  61. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_geometry.py +0 -0
  62. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_microdvd.py +0 -0
  63. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_microdvd_conversion.py +0 -0
  64. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_sami.py +0 -0
  65. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc.py +0 -0
  66. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_translator.py +0 -0
  67. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_scc_writer.py +0 -0
  68. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_srt.py +0 -0
  69. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_srt_conversion.py +0 -0
  70. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_webvtt.py +0 -0
  71. {pycaption-2.3.4 → pycaption-2.3.5}/tests/test_webvtt_conversion.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycaption
3
- Version: 2.3.4
3
+ Version: 2.3.5
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -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 or SCC positional.
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, ignore_region (typically the default region), and
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 or carries a positional anchor (SCC row/col coords),
510
- uses fallback_alignment if provided (per RP 2052-10 center promotion).
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
 
@@ -632,7 +632,6 @@ def _get_layout_from_tuple(position_tuple):
632
632
  return Layout(
633
633
  origin=Point(horizontal, vertical),
634
634
  alignment=Alignment(HorizontalAlignmentEnum.LEFT, VerticalAlignmentEnum.TOP),
635
- is_positional_anchor=True,
636
635
  )
637
636
 
638
637
 
@@ -344,9 +344,6 @@ class WebVTTWriter(BaseWriter):
344
344
  if not layout:
345
345
  return ""
346
346
 
347
- if layout.is_positional_anchor:
348
- return ""
349
-
350
347
  if layout.webvtt_positioning:
351
348
  return f" {layout.webvtt_positioning}"
352
349
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycaption
3
- Version: 2.3.4
3
+ Version: 2.3.5
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -20,7 +20,7 @@ transcript_dependencies = ["nltk==3.10.0"]
20
20
 
21
21
  setup(
22
22
  name="pycaption",
23
- version="2.3.4",
23
+ version="2.3.5",
24
24
  description="Closed caption converter",
25
25
  long_description=open(README_PATH).read(),
26
26
  author="Joe Norton",
@@ -317,7 +317,7 @@ def sample_webvtt_from_scc_properly_writes_newlines_output():
317
317
  return """\
318
318
  WEBVTT
319
319
 
320
- 00:21:30.000 --> 00:21:34.000
320
+ 00:21:30.000 --> 00:21:34.000 align:left position:20% line:83% size:70%
321
321
  aa
322
322
  bb
323
323
  """
@@ -211,10 +211,10 @@ class TestWebVTTtoSAMIStyles(SAMITestingMixIn):
211
211
 
212
212
 
213
213
  class TestSCCtoSAMI(SAMITestingMixIn):
214
- def test_scc_to_sami_center_aligned(self, sample_scc_pop_on):
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:center;" in result
219
- assert "margin-left" not in result
220
- assert "margin-top" not in result
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="center"' in dfxp
46
- assert 'tts:textAlign="left"' not in dfxp
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="center"' in dfxp
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="center"' in dfxp
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