Ciaran Farrell wrote:
2008/8/26 norseman <no******@hughe s.net>:
>frankentux wrote:
>>Ok. Sorted it out, but only after taking a round trip over
xml.minidom . Here's the working code:
#!/usr/bin/python
from odf.opendocumen t import Spreadsheet
from odf.opendocumen t import load
from odf.table import TableRow,TableC ell
from odf.text import P
doc = load("/tmp/match_data.ods" )
d = doc.spreadsheet
rows = d.getElementsBy Type(TableRow)
for row in rows[:2]:
cells = row.getElements ByType(TableCel l)
for cell in cells:
tps = cell.getElement sByType(P)
if len(tps) 0:
for x in tps:
print x.firstChild
--
http://mail.python.org/mailman/listinfo/python-list
============== ===========
cd /opt
find . -name "*odf*" -print
(empty)
cd /usr/local/lib/python2.5
find . -name "*odf*" -print
(empty)
OK - where is it? :)
Sorry. Stupid of me. The module is not part of the standard libary.
It's at http://opendocumentfellowship.com/projects/odfpy
Ciaran
==============
I got the download and all went pretty well. Setup.py compiled OK and
install put it where it belongs.
As a test I went to try odflint and keep getting a zlib not found error.
It is installed (/usr/local/lib) and the python zlib things .py, .pyc
and .pyo all seem present. Not sure what is happening.
I took a look at Python.2.5.2's zipfile.py
statement: import zlib was changed to import libz as zlib
(ALL libs are prefixed with lib... by convention)
Problem below the test happens with or without my change.
Test I ran:
python
(sign on yah de yah yah)
import zipfile
zipfile.is_zipf ile("zx")
False
zipfile.is_zipf ile("zz.zip")
True
zipfile.is_zipf ile("zx.zip")
False (file non existent - no error generated, but answer correct)
Thus all returned correct answers. Distro Python code runs as expected.
However:
odflint OOstuf2.odt |\__
python /usr/local/bin/odflint OOstuf2.odt |/ Both return following:
Traceback (most recent call last):
File "/usr/local/bin/odflint", line 213, in <module>
lint(sys.argv[1])
File "/usr/local/bin/odflint", line 197, in lint
content = zfd.read(zi.fil ename)
File "/usr/local/lib/python2.5/zipfile.py", line 498, in read
"De-compression requires the (missing) zlib module"
RuntimeError: De-compression requires the (missing) zlib module
Anybody:
What did I miss correcting? Seems odflint only uses zipfile.referen ces.
System: Slackware 10.2 on 2.4GgHz Laptop
Steve
no******@hughes .net