From cb054ba6687f71fdbc04e50536643401b30fed3b Mon Sep 17 00:00:00 2001 From: Sebastian Annies Date: Wed, 13 Jun 2018 12:49:16 +0200 Subject: [PATCH] Revert "Merge pull request #156 from pbs/empty-cue" This reverts commit 00804485acf676956437f14ff4fe8b51e197d9c3, reversing changes made to 3d4925d48c88934184ba963b2cf7d5ccdbb02b81. --- pycaption/dfxp/base.py | 11 ++++++----- tests/test_dfxp.py | 21 --------------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/pycaption/dfxp/base.py b/pycaption/dfxp/base.py index e1045715..a8ab7cc2 100644 --- a/pycaption/dfxp/base.py +++ b/pycaption/dfxp/base.py @@ -109,11 +109,8 @@ def _translate_p_tag(self, p_tag): self._translate_tag(p_tag) styles = self._translate_style(p_tag) - if len(self.nodes) > 0: - return Caption( - start, end, self.nodes, style=styles, - layout_info=p_tag.layout_info) - return None + return Caption( + start, end, self.nodes, style=styles, layout_info=p_tag.layout_info) def _find_times(self, p_tag): start = self._translate_time(p_tag['begin']) @@ -183,6 +180,10 @@ def _translate_tag(self, tag): elif tag.name == 'span': # convert span self._translate_span(tag) + elif tag.name == 'p' and not tag.contents: + node = CaptionNode.create_text( + '', layout_info=tag.layout_info) + self.nodes.append(node) else: # recursively call function for any children elements for a in tag.contents: diff --git a/tests/test_dfxp.py b/tests/test_dfxp.py index 131b73a0..62967801 100644 --- a/tests/test_dfxp.py +++ b/tests/test_dfxp.py @@ -117,27 +117,6 @@ def test_empty_paragraph(self): except CaptionReadError: self.fail("Failing on empty paragraph") - def test_empty_cue(self): - caption_set = DFXPReader().read( - SAMPLE_DFXP_EMPTY_CUE) - caps = caption_set.get_captions('en-US') - self.assertEquals(caps[1], []) - -SAMPLE_DFXP_EMPTY_CUE = """\ - - - - - - - - -
-

abc

-

-
- -
""" SAMPLE_DFXP_INVALID_POSITIONING_VALUE_TEMPLATE = """\