pycaption 2.2.8__tar.gz → 2.2.10__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.2.8/pycaption.egg-info → pycaption-2.2.10}/PKG-INFO +1 -1
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/scc/__init__.py +10 -12
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/scc/specialized_collections.py +6 -7
- {pycaption-2.2.8 → pycaption-2.2.10/pycaption.egg-info}/PKG-INFO +1 -1
- {pycaption-2.2.8 → pycaption-2.2.10}/setup.py +1 -1
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/dfxp.py +2 -2
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_scc.py +23 -24
- {pycaption-2.2.8 → pycaption-2.2.10}/LICENSE +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/MANIFEST.in +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/README.rst +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/__init__.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/base.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/dfxp/__init__.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/dfxp/base.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/dfxp/extras.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/english.pickle +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/exceptions.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/geometry.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/microdvd.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/sami.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/scc/constants.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/scc/state_machines.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/scc/translator.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/srt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/transcript.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/utils.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption/webvtt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption.egg-info/SOURCES.txt +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption.egg-info/dependency_links.txt +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption.egg-info/requires.txt +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/pycaption.egg-info/top_level.txt +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/setup.cfg +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/__init__.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/conftest.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/__init__.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/microdvd.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/sami.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/scc.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/srt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/translated_scc.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/fixtures/webvtt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/mixins.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_base.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_dfxp.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_dfxp_conversion.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_dfxp_extras.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_functions.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_geometry.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_microdvd.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_microdvd_conversion.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_sami.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_sami_conversion.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_scc_conversion.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_scc_translator.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_srt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_srt_conversion.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_webvtt.py +0 -0
- {pycaption-2.2.8 → pycaption-2.2.10}/tests/test_webvtt_conversion.py +0 -0
|
@@ -313,15 +313,17 @@ class SCCReader(BaseReader):
|
|
|
313
313
|
for idx, word in enumerate(word_list):
|
|
314
314
|
# ignore empty results or invalid commands
|
|
315
315
|
word = word.strip()
|
|
316
|
-
|
|
316
|
+
previous_is_pac_or_tab = idx > 0 and (
|
|
317
|
+
_is_pac_command(word_list[idx-1]) or word_list[idx-1] in PAC_TAB_OFFSET_COMMANDS
|
|
318
|
+
)
|
|
317
319
|
if len(word) == 4:
|
|
318
320
|
self._translate_word(
|
|
319
321
|
word=word,
|
|
320
|
-
|
|
322
|
+
previous_is_pac_or_tab=previous_is_pac_or_tab,
|
|
321
323
|
pacs_are_doubled=pacs_are_doubled
|
|
322
324
|
)
|
|
323
325
|
|
|
324
|
-
def _translate_word(self, word,
|
|
326
|
+
def _translate_word(self, word, previous_is_pac_or_tab, pacs_are_doubled):
|
|
325
327
|
if self._handle_double_command(word, pacs_are_doubled):
|
|
326
328
|
# count frames for timing
|
|
327
329
|
self.time_translator.increment_frames()
|
|
@@ -330,7 +332,7 @@ class SCCReader(BaseReader):
|
|
|
330
332
|
# TODO - check that all the positioning commands are here, or use
|
|
331
333
|
# some other strategy to determine if the word is a command.
|
|
332
334
|
if word in COMMANDS or _is_pac_command(word):
|
|
333
|
-
self._translate_command(word=word,
|
|
335
|
+
self._translate_command(word=word, previous_is_pac_or_tab=previous_is_pac_or_tab)
|
|
334
336
|
|
|
335
337
|
# second, check if word is a special character
|
|
336
338
|
elif word in SPECIAL_CHARS:
|
|
@@ -354,14 +356,12 @@ class SCCReader(BaseReader):
|
|
|
354
356
|
# If we have doubled commands we're skipping also
|
|
355
357
|
# doubled special characters and doubled extended characters
|
|
356
358
|
# with only one member of each pair being displayed.
|
|
357
|
-
|
|
358
|
-
key: COMMANDS[key] for key in COMMANDS.keys() if key != "94a1"
|
|
359
|
-
}
|
|
360
|
-
doubled_types = word in actionable_commands or _is_pac_command(word)
|
|
359
|
+
doubled_types = word in COMMANDS or _is_pac_command(word)
|
|
361
360
|
if pacs_are_doubled:
|
|
362
361
|
doubled_types = doubled_types or word in SPECIAL_CHARS or word in EXTENDED_CHARS
|
|
363
362
|
|
|
364
363
|
if doubled_types and word == self.last_command:
|
|
364
|
+
self.last_command = ''
|
|
365
365
|
return True
|
|
366
366
|
# Fix for the <position> <tab offset> <position> <tab offset>
|
|
367
367
|
# repetition
|
|
@@ -379,8 +379,6 @@ class SCCReader(BaseReader):
|
|
|
379
379
|
return False
|
|
380
380
|
|
|
381
381
|
def _translate_special_char(self, word):
|
|
382
|
-
self.buffer.handle_backspace(word)
|
|
383
|
-
# add to buffer
|
|
384
382
|
self.buffer.add_chars(SPECIAL_CHARS[word])
|
|
385
383
|
|
|
386
384
|
def _translate_extended_char(self, word):
|
|
@@ -395,7 +393,7 @@ class SCCReader(BaseReader):
|
|
|
395
393
|
# add to buffer
|
|
396
394
|
self.buffer.add_chars(EXTENDED_CHARS[word])
|
|
397
395
|
|
|
398
|
-
def _translate_command(self, word,
|
|
396
|
+
def _translate_command(self, word, previous_is_pac_or_tab):
|
|
399
397
|
# if command is pop_up
|
|
400
398
|
if word == '9420':
|
|
401
399
|
self.buffer_dict.set_active('pop')
|
|
@@ -466,7 +464,7 @@ class SCCReader(BaseReader):
|
|
|
466
464
|
else:
|
|
467
465
|
self.buffer.interpret_command(
|
|
468
466
|
command=word,
|
|
469
|
-
|
|
467
|
+
previous_is_pac_or_tab=previous_is_pac_or_tab
|
|
470
468
|
)
|
|
471
469
|
|
|
472
470
|
def _translate_characters(self, word):
|
|
@@ -337,14 +337,15 @@ class InstructionNodeCreator:
|
|
|
337
337
|
|
|
338
338
|
node.add_chars(*chars)
|
|
339
339
|
|
|
340
|
-
def interpret_command(self, command,
|
|
340
|
+
def interpret_command(self, command, previous_is_pac_or_tab=False):
|
|
341
341
|
"""Given a command determines whether to turn italics on or off,
|
|
342
342
|
or to set the positioning
|
|
343
343
|
|
|
344
344
|
This is mostly used to convert from the legacy-style commands
|
|
345
345
|
|
|
346
346
|
:type command: str
|
|
347
|
-
:type
|
|
347
|
+
:type previous_is_pac_or_tab: previous command code is for a PAC command
|
|
348
|
+
or a PAC_TAB_OFFSET_COMMANDS
|
|
348
349
|
"""
|
|
349
350
|
self._update_positioning(command)
|
|
350
351
|
|
|
@@ -382,8 +383,7 @@ class InstructionNodeCreator:
|
|
|
382
383
|
|
|
383
384
|
# mid row code that is not first code on the line
|
|
384
385
|
# (previous node is not a break node)
|
|
385
|
-
|
|
386
|
-
if command in MID_ROW_CODES and not previous_is_pac:
|
|
386
|
+
if command in MID_ROW_CODES and not previous_is_pac_or_tab:
|
|
387
387
|
if self.last_style == "italics off":
|
|
388
388
|
self.add_chars(' ')
|
|
389
389
|
else:
|
|
@@ -456,12 +456,11 @@ class InstructionNodeCreator:
|
|
|
456
456
|
return
|
|
457
457
|
last_char = node.text[-1]
|
|
458
458
|
delete_previous_condition = (
|
|
459
|
-
(word in SPECIAL_CHARS and last_char not in SPECIAL_CHARS.values()) or
|
|
460
459
|
(word in EXTENDED_CHARS and last_char not in EXTENDED_CHARS.values()) or
|
|
461
460
|
word == "94a1"
|
|
462
461
|
)
|
|
463
|
-
# in case
|
|
464
|
-
# only if the previous character in not also
|
|
462
|
+
# in case extended char, perform backspace
|
|
463
|
+
# only if the previous character in not also extended
|
|
465
464
|
if delete_previous_condition:
|
|
466
465
|
node.text = node.text[:-1]
|
|
467
466
|
|
|
@@ -920,10 +920,10 @@ def sample_dfxp_from_scc_output():
|
|
|
920
920
|
<region tts:displayAlign="before" tts:origin="40% 53%" tts:textAlign="left" xml:id="r5"/>
|
|
921
921
|
<region tts:displayAlign="before" tts:origin="70% 17%" tts:textAlign="left" xml:id="r6"/>
|
|
922
922
|
<region tts:displayAlign="before" tts:origin="20% 35%" tts:textAlign="left" xml:id="r7"/>
|
|
923
|
-
<region tts:displayAlign="before" tts:origin="
|
|
923
|
+
<region tts:displayAlign="before" tts:origin="20% 83%" tts:textAlign="left" xml:id="r8"/>
|
|
924
924
|
<region tts:displayAlign="before" tts:origin="70% 11%" tts:textAlign="left" xml:id="r9"/>
|
|
925
925
|
<region tts:displayAlign="before" tts:origin="40% 41%" tts:textAlign="left" xml:id="r10"/>
|
|
926
|
-
<region tts:displayAlign="before" tts:origin="
|
|
926
|
+
<region tts:displayAlign="before" tts:origin="20% 71%" tts:textAlign="left" xml:id="r11"/>
|
|
927
927
|
</layout>
|
|
928
928
|
</head>
|
|
929
929
|
<body>
|
|
@@ -77,10 +77,10 @@ class TestSCCReader(ReaderTestingMixIn):
|
|
|
77
77
|
((40.0, UnitEnum.PERCENT), (53.0, UnitEnum.PERCENT)),
|
|
78
78
|
((70.0, UnitEnum.PERCENT), (17.0, UnitEnum.PERCENT)),
|
|
79
79
|
((20.0, UnitEnum.PERCENT), (35.0, UnitEnum.PERCENT)),
|
|
80
|
-
((
|
|
80
|
+
((20.0, UnitEnum.PERCENT), (83.0, UnitEnum.PERCENT)),
|
|
81
81
|
((70.0, UnitEnum.PERCENT), (11.0, UnitEnum.PERCENT)),
|
|
82
82
|
((40.0, UnitEnum.PERCENT), (41.0, UnitEnum.PERCENT)),
|
|
83
|
-
((
|
|
83
|
+
((20.0, UnitEnum.PERCENT), (71.0, UnitEnum.PERCENT))
|
|
84
84
|
]
|
|
85
85
|
actual_positioning = [
|
|
86
86
|
caption_.layout_info.origin.serialized()
|
|
@@ -204,10 +204,10 @@ class TestSCCReader(ReaderTestingMixIn):
|
|
|
204
204
|
|
|
205
205
|
def test_skip_duplicate_tab_offset(self, sample_scc_duplicate_tab_offset):
|
|
206
206
|
expected_lines = [
|
|
207
|
-
'[Radio reporter]
|
|
208
|
-
'The I-10 Santa Monica Freeway
|
|
207
|
+
'[Radio reporter]',
|
|
208
|
+
'The I-10 Santa Monica Freeway',
|
|
209
209
|
'westbound is jammed,',
|
|
210
|
-
'due to a three-car accident
|
|
210
|
+
'due to a three-car accident',
|
|
211
211
|
'blocking lanes 1 and 2'
|
|
212
212
|
]
|
|
213
213
|
|
|
@@ -218,15 +218,14 @@ class TestSCCReader(ReaderTestingMixIn):
|
|
|
218
218
|
for node in cap_.nodes
|
|
219
219
|
if node.type_ == CaptionNode.TEXT
|
|
220
220
|
]
|
|
221
|
-
|
|
222
221
|
assert expected_lines == actual_lines
|
|
223
222
|
|
|
224
223
|
def test_skip_duplicate_special_characters(
|
|
225
224
|
self, sample_scc_duplicate_special_characters):
|
|
226
225
|
expected_lines = [
|
|
227
|
-
'®°½¿™¢£♪à èâêîôû',
|
|
228
|
-
'®°½¿™¢£♪à èâêîôû',
|
|
229
|
-
'®°
|
|
226
|
+
'®°½¿™¢£♪à èâêîôû',
|
|
227
|
+
'®°½¿™¢£♪à èâêîôû',
|
|
228
|
+
'®°AA½¿™¢£♪à èâêAAîôû'
|
|
230
229
|
]
|
|
231
230
|
|
|
232
231
|
caption_set = SCCReader().read(sample_scc_duplicate_special_characters)
|
|
@@ -274,21 +273,21 @@ class TestCoverageOnly:
|
|
|
274
273
|
actual_texts = [cap_.nodes[0].content for cap_ in captions]
|
|
275
274
|
expected_texts = [
|
|
276
275
|
'>>> HI.',
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
276
|
+
"I'M KEVIN CUNNING AND AT",
|
|
277
|
+
"INVESTOR'S BANK WE BELIEVE IN",
|
|
278
|
+
'HELPING THE LOCAL NEIGHBORHOODS',
|
|
279
|
+
'AND IMPROVING THE LIVES OF ALL',
|
|
280
|
+
'WE SERVE.',
|
|
281
|
+
'®°½',
|
|
282
|
+
'ABû',
|
|
283
|
+
'ÁÉÓ¡',
|
|
284
|
+
"WHERE YOU'RE STANDING NOW,",
|
|
285
|
+
"LOOKING OUT THERE, THAT'S AL",
|
|
286
|
+
'THE CROWD.',
|
|
287
|
+
'>> IT WAS GOOD TO BE IN TH',
|
|
288
|
+
"And restore Iowa's land, water",
|
|
289
|
+
'And wildlife.',
|
|
290
|
+
'>> Bike Iowa, your source for'
|
|
292
291
|
]
|
|
293
292
|
assert expected_texts == actual_texts
|
|
294
293
|
|
|
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
|