Skip to content

Commit

Permalink
OCTO-10874-ascii-duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
OlteanuRares committed Dec 5, 2023
1 parent 4fe2335 commit 5f8a81c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pycaption/scc/specialized_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
from .constants import (
PAC_BYTES_TO_POSITIONING_MAP, COMMANDS, PAC_TAB_OFFSET_COMMANDS,
MICROSECONDS_PER_CODEWORD,
MICROSECONDS_PER_CODEWORD, EXTENDED_CHARS, CHARACTERS
)

PopOnCue = collections.namedtuple("PopOnCue", "buffer, start, end")
Expand Down Expand Up @@ -423,11 +423,11 @@ def remove_ascii_duplicate(self, accented_character):
:type accented_character: str
"""
if self._collection and self._collection[-1].is_text_node() and \
self._collection[-1].text:
ascii_char = unicodedata.normalize('NFD', accented_character)\
.encode('ascii', 'ignore').decode("utf-8")
if ascii_char and self._collection[-1].text[-1] == ascii_char:
is_text_node = self._collection and self._collection[-1].is_text_node() and self._collection[-1].text
if is_text_node:
last_char = self._collection[-1].text[-1]
is_char = last_char in CHARACTERS.values() or last_char in EXTENDED_CHARS.values()
if is_char:
self._collection[-1].text = self._collection[-1].text[:-1]


Expand Down
4 changes: 2 additions & 2 deletions tests/test_scc.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def test_freeze_rollup_captions_contents(self, sample_scc_roll_up_ru2):
'WE SERVE.',
'®°½',
'ABû',
'ÁÁÉÓ¡',
# 'ÁÁÉÓ¡',
'¡',
"WHERE YOU'RE STANDING NOW,",
"LOOKING OUT THERE, THAT'S AL",
'THE CROWD.',
Expand All @@ -272,7 +273,6 @@ def test_freeze_rollup_captions_contents(self, sample_scc_roll_up_ru2):
'And wildlife.',
'>> Bike Iowa, your source for',
]

assert expected_texts == actual_texts

def test_multiple_formats(self, sample_scc_multiple_formats):
Expand Down

0 comments on commit 5f8a81c

Please sign in to comment.