views:

678

answers:

3

I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.

It seem's ODFPy is a wonderful library for this porpouse. Unfortunately the official documentation is very poor, almost unuseful. And I can't find almost anything online (maybe it is not so popular?).

Is there anyone who can give me a peace of information? Do you know internet sites where I can find a little more documentation?

Thanks.

L

A: 

Okay, here's a quick help:

  1. Grab odfpy source code:

    ~$ svn checkout https://svn.forge.osor.eu/svn/odfpy/trunk odfpy
    
  2. Install it:

     ~$ cd odfpy
     ~/odfpy$ python setup.py install
    
  3. Generate the documentation:

    ~/odfpy$ epydoc --pdf odf
    

    I have uploaded the generated documentation here.

  4. Run this simple example program:

    from odf.opendocument import OpenDocumentText
    from odf.text import P    
    textdoc = OpenDocumentText()
    p = P(text="Hello World!")
    textdoc.text.addElement(p)
    textdoc.save("helloworld", True)
    
  5. Read the examples and try to make sense of everything:

    ~/odfpy$ emacs examples/*.py
    

Hope that helps! Good luck!

nosklo
This is still the same official documentation that the original poster is (rightfully) complaining about.
Nick Bastin
+1  A: 

The documentation is unfortunately horrible, and the generated Python wrapper is lousily documented in code, providing lots of functions whose argument lists look like func(*args).

The reference manual is actually useful, but not when you're starting out - it doesn't provide any context of how to use these functions. I would suggest starting with the tutorial and all the examples. Even though they may have nothing to do with your use case, they will help you get the feel of how the package works. After you've gotten used to the way the package is structured, you can often make sense of the documentation by combining the API doc with the information in the OpenDocument Essentials book.

(The relationship is somewhat tenuous at best, but you can often intuit method and attribute values from it. When working with the spreadsheet, for example, the handy list of office:value-type data in the book provided the necessary constants for building proper TableCell(valuetype=...) instances)

Also, making small documents in OpenOffice and then inspecting the xml and comparing it to the XML generated from ODFPy greatly helps you debug where you might have gone wrong.

Nick Bastin
A: 

was written very fast: http://repo.or.cz/w/openbaar_schrijver.git

osp