pycaption 2.2.8__tar.gz → 2.2.9__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 (58) hide show
  1. {pycaption-2.2.8/pycaption.egg-info → pycaption-2.2.9}/PKG-INFO +1 -1
  2. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/scc/__init__.py +9 -12
  3. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/scc/specialized_collections.py +6 -7
  4. {pycaption-2.2.8 → pycaption-2.2.9/pycaption.egg-info}/PKG-INFO +1 -1
  5. {pycaption-2.2.8 → pycaption-2.2.9}/setup.py +1 -1
  6. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_scc.py +21 -22
  7. {pycaption-2.2.8 → pycaption-2.2.9}/LICENSE +0 -0
  8. {pycaption-2.2.8 → pycaption-2.2.9}/MANIFEST.in +0 -0
  9. {pycaption-2.2.8 → pycaption-2.2.9}/README.rst +0 -0
  10. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/__init__.py +0 -0
  11. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/base.py +0 -0
  12. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/dfxp/__init__.py +0 -0
  13. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/dfxp/base.py +0 -0
  14. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/dfxp/extras.py +0 -0
  15. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/english.pickle +0 -0
  16. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/exceptions.py +0 -0
  17. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/geometry.py +0 -0
  18. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/microdvd.py +0 -0
  19. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/sami.py +0 -0
  20. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/scc/constants.py +0 -0
  21. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/scc/state_machines.py +0 -0
  22. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/scc/translator.py +0 -0
  23. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/srt.py +0 -0
  24. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/transcript.py +0 -0
  25. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/utils.py +0 -0
  26. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption/webvtt.py +0 -0
  27. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption.egg-info/SOURCES.txt +0 -0
  28. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption.egg-info/dependency_links.txt +0 -0
  29. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption.egg-info/requires.txt +0 -0
  30. {pycaption-2.2.8 → pycaption-2.2.9}/pycaption.egg-info/top_level.txt +0 -0
  31. {pycaption-2.2.8 → pycaption-2.2.9}/setup.cfg +0 -0
  32. {pycaption-2.2.8 → pycaption-2.2.9}/tests/__init__.py +0 -0
  33. {pycaption-2.2.8 → pycaption-2.2.9}/tests/conftest.py +0 -0
  34. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/__init__.py +0 -0
  35. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/dfxp.py +0 -0
  36. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/microdvd.py +0 -0
  37. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/sami.py +0 -0
  38. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/scc.py +0 -0
  39. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/srt.py +0 -0
  40. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/translated_scc.py +0 -0
  41. {pycaption-2.2.8 → pycaption-2.2.9}/tests/fixtures/webvtt.py +0 -0
  42. {pycaption-2.2.8 → pycaption-2.2.9}/tests/mixins.py +0 -0
  43. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_base.py +0 -0
  44. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_dfxp.py +0 -0
  45. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_dfxp_conversion.py +0 -0
  46. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_dfxp_extras.py +0 -0
  47. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_functions.py +0 -0
  48. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_geometry.py +0 -0
  49. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_microdvd.py +0 -0
  50. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_microdvd_conversion.py +0 -0
  51. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_sami.py +0 -0
  52. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_sami_conversion.py +0 -0
  53. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_scc_conversion.py +0 -0
  54. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_scc_translator.py +0 -0
  55. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_srt.py +0 -0
  56. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_srt_conversion.py +0 -0
  57. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_webvtt.py +0 -0
  58. {pycaption-2.2.8 → pycaption-2.2.9}/tests/test_webvtt_conversion.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycaption
3
- Version: 2.2.8
3
+ Version: 2.2.9
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -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
- previous_is_pac = idx > 0 and _is_pac_command(word_list[idx-1])
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
- previous_is_pac=previous_is_pac,
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, previous_is_pac, pacs_are_doubled):
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, previous_is_pac=previous_is_pac)
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,10 +356,7 @@ 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
- actionable_commands = {
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
 
@@ -379,8 +378,6 @@ class SCCReader(BaseReader):
379
378
  return False
380
379
 
381
380
  def _translate_special_char(self, word):
382
- self.buffer.handle_backspace(word)
383
- # add to buffer
384
381
  self.buffer.add_chars(SPECIAL_CHARS[word])
385
382
 
386
383
  def _translate_extended_char(self, word):
@@ -395,7 +392,7 @@ class SCCReader(BaseReader):
395
392
  # add to buffer
396
393
  self.buffer.add_chars(EXTENDED_CHARS[word])
397
394
 
398
- def _translate_command(self, word, previous_is_pac):
395
+ def _translate_command(self, word, previous_is_pac_or_tab):
399
396
  # if command is pop_up
400
397
  if word == '9420':
401
398
  self.buffer_dict.set_active('pop')
@@ -466,7 +463,7 @@ class SCCReader(BaseReader):
466
463
  else:
467
464
  self.buffer.interpret_command(
468
465
  command=word,
469
- previous_is_pac=previous_is_pac
466
+ previous_is_pac_or_tab=previous_is_pac_or_tab
470
467
  )
471
468
 
472
469
  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, previous_is_pac=None):
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 mode: pop or roll or paint
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
- # fixes OCTO-11022
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 of special / extended char, perform backspace
464
- # only if the previous character in not also special / extended
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycaption
3
- Version: 2.2.8
3
+ Version: 2.2.9
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -24,7 +24,7 @@ transcript_dependencies = [
24
24
 
25
25
  setup(
26
26
  name='pycaption',
27
- version='2.2.8',
27
+ version='2.2.9',
28
28
  description='Closed caption converter',
29
29
  long_description=open(README_PATH).read(),
30
30
  author='Joe Norton',
@@ -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
- '®°½¿™¢£♪à èâêîôû', # double commands so we skip one
228
- '®°½¿™¢£♪à èâêîôû', # no double command, nothing skipped equal with above
229
- '®°A½¿™¢£♪à èâêAîôû' # no skips but a couple of normal chars "c1c1" = AA
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
- "I'M KEVIN CUNNING AND AT",
278
- "INVESTOR'S BANK WE BELIEVE IN",
279
- 'HELPING THE LOCAL NEIGHBORHOODS',
280
- 'AND IMPROVING THE LIVES OF ALL',
281
- 'WE SERVE.',
282
- '®°½',
283
- '',
284
- 'ÁÉÓ¡',
285
- "WHERE YOU'RE STANDING NOW,",
286
- "LOOKING OUT THERE, THAT'S AL",
287
- 'THE CROWD.',
288
- '>> IT WAS GOOD TO BE IN TH',
289
- "And restore Iowa's land, water",
290
- 'And wildlife.',
291
- '>> Bike Iowa, your source for'
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