ooopy: newbie cannot get basic functionality to work

Andrew Sackville-West andrew at farwestbilliards.com
Sat Dec 9 21:44:37 EST 2006


Hi list, 

I am new to python and old to coding (as in I did it a long time
ago). I've got a task that cries out for a scripted solution --
importing chunks of ASCII data dumps from a point-of-sale system into
an openoffice.org spreadsheet. What a great chance for me to get my
coding skills back and learn python too!

I have attempted to get ooopy to work for me and have run into
problems at the first step. Google returns not much on ooopy and the
common example, from help (OOoPy) is:

     |  from OOoPy import OOoPy
     |  >>> o = OOoPy (infile = 'test.sxw', outfile = 'out.sxw')
     |  >>> e = o.read ('content.xml')
     |  >>> e.write ()
     |  >>> o.close ()

okay here goes:

>>> from OOoPy import OOoPy
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named OOoPy

hmm... okay how about:

>>> from ooopy import OOoPy
>>> dir (OOoPy)
['ElementTree', 'OOoElementTree', 'OOoPy', 'StringIO', 'VERSION',
'ZIP_DEFLATED', 'ZipFile', '__builtins__', '__doc__', '__file__',
'__name__', '_autosuper', 'autosuper', 'fromstring', 'mkstemp', 'os']

okay that works. now:

>>> o = OOoPy (infile='/home/andrew/monthly.ods')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable
>>>

that's not good. at this point, I'm stuck. I've tried various
permutations of this with no other results. It also fails on the
sample file provided with ooopy, test.sxw. 

I have seen one solution using zip to get the contents of the oo.o
file which would probably work but would like to figure this out.

I have installed ooopy using setup.py provided with the package on
debian sid, up-to-date. And I've tried it using python 2.3 and 2.4. 

any help appreciated. thanks

A

>>>import sys
>>> sys.path
['', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/PIL',
'/var/lib/python-support/python2.4']
>>> sys.modules
{'tokenize': <module 'tokenize' from
'/usr/lib/python2.4/tokenize.pyc'>, 'copy_reg': <module 'copy_reg'
from '/usr/lib/python2.4/copy_reg.pyc'>, 'sre_compile': <module
'sre_compile' from '/usr/lib/python2.4/sre_compile.pyc'>,
'ooopy.StringIO': None, '_sre': <module '_sre' (built-in)>,
'__main__': <module '__main__' (built-in)>, 'ooopy.os': None, 'site':
<module 'site' from '/usr/lib/python2.4/site.pyc'>, '__builtin__':
<module '__builtin__' (built-in)>, 'elementtree.ElementTree': <module
'elementtree.ElementTree' from
'/var/lib/python-support/python2.4/elementtree/ElementTree.pyc'>,
'encodings': <module 'encodings' from
'/usr/lib/python2.4/encodings/__init__.pyc'>, 'array': <module 'array'
from '/usr/lib/python2.4/lib-dynload/array.so'>, 'pydoc': <module
'pydoc' from '/usr/lib/python2.4/pydoc.pyc'>, 'posixpath': <module
'posixpath' from '/usr/lib/python2.4/posixpath.pyc'>, '_random':
<module '_random' from '/usr/lib/python2.4/lib-dynload/_random.so'>,
'imp': <module 'imp' (built-in)>, 'tempfile': <module 'tempfile' from
'/usr/lib/python2.4/tempfile.pyc'>, 'errno': <module 'errno'
(built-in)>, 'binascii': <module 'binascii' from
'/usr/lib/python2.4/lib-dynload/binascii.so'>, 'encodings.codecs':
None, 'sre_constants': <module 'sre_constants' from
'/usr/lib/python2.4/sre_constants.pyc'>, 're': <module 're' from
'/usr/lib/python2.4/re.pyc'>, 'encodings.latin_1': <module
'encodings.latin_1' from '/usr/lib/python2.4/encodings/latin_1.pyc'>,
'collections': <module 'collections' from
'/usr/lib/python2.4/lib-dynload/collections.so'>, 'os.path': <module
'posixpath' from '/usr/lib/python2.4/posixpath.pyc'>, '_codecs':
<module '_codecs' (built-in)>, 'opcode': <module 'opcode' from
'/usr/lib/python2.4/opcode.pyc'>, 'encodings.exceptions': None, 'sre':
<module 'sre' from '/usr/lib/python2.4/sre.pyc'>, 'math': <module
'math' from '/usr/lib/python2.4/lib-dynload/math.so'>, 'fcntl':
<module 'fcntl' from '/usr/lib/python2.4/lib-dynload/fcntl.so'>,
'stat': <module 'stat' from '/usr/lib/python2.4/stat.pyc'>,
'zipimport': <module 'zipimport' (built-in)>, 'string': <module
'string' from '/usr/lib/python2.4/string.pyc'>, 'inspect': <module
'inspect' from '/usr/lib/python2.4/inspect.pyc'>, 'warnings': <module
'warnings' from '/usr/lib/python2.4/warnings.pyc'>, 'encodings.types':
None, 'UserDict': <module 'UserDict' from
'/usr/lib/python2.4/UserDict.pyc'>, 'ooopy.Version': <module
'ooopy.Version' from '/usr/lib/python2.4/ooopy/Version.py'>,
'zipfile': <module 'zipfile' from '/usr/lib/python2.4/zipfile.pyc'>,
'repr': <module 'repr' from '/usr/lib/python2.4/repr.pyc'>, 'sys':
<module 'sys' (built-in)>, 'ooopy.elementtree': None,
'ooopy.tempfile': None, 'itertools': <module 'itertools' from
'/usr/lib/python2.4/lib-dynload/itertools.so'>, 'codecs': <module
'codecs' from '/usr/lib/python2.4/codecs.pyc'>, 'readline': <module
'readline' from '/usr/lib/python2.4/lib-dynload/readline.so'>,
'elementtree': <module 'elementtree' from
'/var/lib/python-support/python2.4/elementtree/__init__.pyc'>,
'ooopy.OOoPy': <module 'ooopy.OOoPy' from
'/usr/lib/python2.4/ooopy/OOoPy.py'>, 'types': <module 'types' from
'/usr/lib/python2.4/types.pyc'>, 'struct': <module 'struct' from
'/usr/lib/python2.4/lib-dynload/struct.so'>, 'elementtree.string':
None, 'thread': <module 'thread' (built-in)>, 'StringIO': <module
'StringIO' from '/usr/lib/python2.4/StringIO.pyc'>, 'ooopy.zipfile':
None, 'strop': <module 'strop' from
'/usr/lib/python2.4/lib-dynload/strop.so'>, 'signal': <module 'signal'
(built-in)>, 'zlib': <module 'zlib' from
'/usr/lib/python2.4/lib-dynload/zlib.so'>, 'elementtree.ElementPath':
<module 'elementtree.ElementPath' from
'/var/lib/python-support/python2.4/elementtree/ElementPath.pyc'>,
'random': <module 'random' from '
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20061209/797f7870/attachment.sig>


More information about the Python-list mailing list