💚 🔬 🎨 fix the broken test, code refactor the whitespace handler
This commit is contained in:
parent
ffce4b26a2
commit
a180d610e5
|
@ -24,7 +24,7 @@
|
|||
# Thanks to grt for the fixes
|
||||
import math
|
||||
|
||||
from odf import teletype
|
||||
from odf.teletype import extractText
|
||||
from odf.table import TableRow, TableCell, Table
|
||||
from odf.text import P
|
||||
from odf.namespaces import OFFICENS
|
||||
|
@ -88,16 +88,10 @@ class ODSSheet(SheetReader):
|
|||
|
||||
def __read_text_cell(self, cell):
|
||||
text_content = []
|
||||
paragraphs = teletype.extractText(cell.getElementsByType(P))
|
||||
paragraphs = cell.getElementsByType(P)
|
||||
# for each text node
|
||||
for paragraph in paragraphs:
|
||||
data = ''
|
||||
for node in paragraph.childNodes:
|
||||
if (node.nodeType == 3):
|
||||
if PY2:
|
||||
data += unicode(node.data)
|
||||
else:
|
||||
data += node.data
|
||||
data = extractText(paragraph)
|
||||
text_content.append(data)
|
||||
return '\n'.join(text_content)
|
||||
|
||||
|
|
Binary file not shown.
|
@ -131,5 +131,12 @@ def test_issue_83_ods_file_handle():
|
|||
eq_(open_files_l1, open_files_l4)
|
||||
|
||||
|
||||
def test_pr_22():
|
||||
test_file = get_fixtures("white_space.ods")
|
||||
data = get_data(test_file)
|
||||
# OrderedDict([(u'Sheet1', [[u'paragraph with tab, space, new line']])])
|
||||
eq_(data['Sheet1'][0][0], 'paragraph with tab(\t), space, \nnew line')
|
||||
|
||||
|
||||
def get_fixtures(filename):
|
||||
return os.path.join("tests", "fixtures", filename)
|
||||
|
|
Loading…
Reference in New Issue