Skip to content

Commit

Permalink
Revert "Merge pull request pbs#156 from pbs/empty-cue"
Browse files Browse the repository at this point in the history
This reverts commit 0080448, reversing
changes made to 3d4925d.
  • Loading branch information
sannies committed Jun 13, 2018
1 parent 52f6253 commit cb054ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
11 changes: 6 additions & 5 deletions pycaption/dfxp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 0 additions & 21 deletions tests/test_dfxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """\
<?xml version="1.0" encoding="utf-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling">
<head>
<layout>
<region tts:origin="10% 10%" xml:id="bottom"/>
</layout>
</head>
<body>
<div region="bottom" xml:lang="en-US">
<p begin="00:00:01.209" end="00:00:02.312" region="bottom">abc</p>
<p begin="00:00:09.209" end="00:00:12.312" region="bottom"></p>
</div>
</body>
</tt>"""

SAMPLE_DFXP_INVALID_POSITIONING_VALUE_TEMPLATE = """\
<?xml version="1.0" encoding="utf-8"?>
Expand Down

0 comments on commit cb054ba

Please sign in to comment.