From: nico h <nh...@la...> - 2008-02-23 00:50:09
|
>>>hi ! i installed docutils on a ubuntu machine (dapper) using the python-docutils package with synaptic. then i downloaded rst2odt and installed it $ python setup.py build $ sudo python setup.py install then i created a short text document and tried to run rst2odt.py : nico@tezcatlipoca:~/temp$ rst2odt.py essai_txt2odt.txt essai_txt2odt.odt Traceback (most recent call last): File "/usr/bin/rst2odt.py", line 21, in ? from docutils.writers.odtwriter import Writer ImportError: No module named odtwriter nico@tezcatlipoca:~/temp$ looking for help on internet about this error message, i found some help on this mailing list, but it was not enough. i noticed that docutils seems to be installed in this directory : /usr/lib/site-python/docutils/ (where lots of files and subdirectories can be found, like core.py, languages, parsers, readers etc.) but odtwriter is installed in this one : /usr/lib/python2.4/site-packages/docutils/ and seems to be absolutely alone there : nico@tezcatlipoca:~$ ls /usr/lib/python2.4/site-packages/docutils/ writers nico@tezcatlipoca:~$ ls /usr/lib/python2.4/site-packages/docutils/writers/ odtwriter nico@tezcatlipoca:~$ the PYTHONPATH is clear : nico@tezcatlipoca:~$ echo $PYTHONPATH nico@tezcatlipoca:~$ and sys.path seems to be quite "full" : nico@tezcatlipoca:~$ python2.4 Python 2.4.3 (#2, Oct 6 2006, 07:52:30) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print 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/HTMLgen', '/usr/lib/python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/PIL', '/usr/lib/python2.4/site-packages/cairo', '/usr/lib/python2.4/site-packages/gst-0.10', '/usr/lib/python2.4/site-packages/gtk-2.0', '/usr/lib/site-python'] >>> both /usr/lib/python2.4/site-packages and /usr/lib/site-python are there so it should find the two docutils directories. and by the way : >>> import docutils >>> docutils <module 'docutils' from '/usr/lib/site-python/docutils/__init__.pyc'> >>> so it's like python finds the /usr/lib/site-python/docutils/ package but totally ignores the /usr/lib/python2.4/site-packages/docutils one, although its path also appears in the sys.path i tried some dirty little tricks like : nico@tezcatlipoca:~$ sudo ln -s /usr/lib/python2.4/site-packages/docutils/writers/odtwriter/ /usr/lib/site-python/docutils/writers/odtwriter and this one almost worked (note : moving the odtwriter had the same effect). i got then a new error message indicating that IPython.Shell couldn't be found (called from this line : "from IPython.Shell import IPShellEmbed" ) investigating the file where the error comes from, i just noticed then that this IPython.Shell class was only useful for debuging so i commented out these lines and tried again. there it worked for a simple text file... but when i tried to add a raw directive, it didn't work any longer, i got a kind of error again : nico@tezcatlipoca:~$ rst2odt.py essai_txt2odt.txt essai_txt2odt.odt missing visit_raw missing depart_raw nico@tezcatlipoca:~$ i guess it tries to find visit_raw and depart_raw methods but doesn't... and i tried to find where these *_raw methods could be but didn't find anything that i could manage to change or "fix". and well, i guess this new problem is linked, again, to this installation directory problem. so i decided stopping to cheat and finally ask for help because i don't manage any further investigation without help :o) i don't really know what can be changed in order to tell python that it really has the right to explore the different directories in its sys.path or... install all the packages (including odtwriter) at the same place or... whatever can help ! i'm writing a python program to generate documents automatically. it generates them in LaTeX and i'd like to have them in .odt too. so, i'm exploring this docutils package which may be really useful for my project. thanks for any help ! |
From: nico h <nh...@la...> - 2008-02-23 09:20:20
|
nico h <nh_pub <at> laposte.net> writes: > > >>>hi ! > > i installed docutils on a ubuntu machine (dapper) using the python-docutils > package with synaptic. > > then i downloaded rst2odt and installed it > $ python setup.py build > $ sudo python setup.py install > > then i created a short text document and tried to run rst2odt.py : > > nico <at> tezcatlipoca:~/temp$ rst2odt.py essai_txt2odt.txt essai_txt2odt.odt > Traceback (most recent call last): > File "/usr/bin/rst2odt.py", line 21, in ? > from docutils.writers.odtwriter import Writer > ImportError: No module named odtwriter > nico <at> tezcatlipoca:~/temp$ > well i think i finally managed to fix the installation directories problem : despite this post : http://article.gmane.org/gmane.text.docutils.user/2221 i deinstalled python-docutils via synaptic and then reinstalled it from the snapshot tgz. this one installed itself in the /usr/lib/python2.4/site-packages/ directory, just where odtwriter already was and this time, there was no error like ImportError but the next problem isn't actually solved : > > but when i tried to add a raw directive, it didn't work any longer, i > got a kind of error again : > nico <at> tezcatlipoca:~$ rst2odt.py essai_txt2odt.txt essai_txt2odt.odt > missing visit_raw > missing depart_raw > nico <at> tezcatlipoca:~$ > some greps helped me to figure out that these two messages come from an exception (like NameValueError ?) but i don't know what's missing. there are some visit_raw and depart_raw methods in the different .py files. i didn't understand from the documentation that i had to install anything more to use a "raw" directive. documentation tells that the raw directive is enabled by default. PS i've run the alltests.py but didn't get any problem : nico@tezcatlipoca:~/Arrivages/docutils/test$ ./alltests.py Testing Docutils 0.5 [snapshot 2008-02-23, r5513] with Python 2.4.3 on 2008-02-23 at 09:55:08 Working directory: /home/nico/Arrivages/docutils/test Docutils package: /home/nico/Arrivages/docutils/docutils ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ...................................................................... ... ---------------------------------------------------------------------- Ran 1053 tests in 25.062s OK Elapsed time: 26.498 seconds nico@tezcatlipoca:~/Arrivages/docutils/test$ |
From: G. M. <mi...@us...> - 2008-02-25 10:37:06
|
On 23.02.08, nico h wrote: > nico h <nh_pub <at> laposte.net> writes: > > when i tried to add a raw directive, it didn't work any longer, i > > got a kind of error again : > > nico <at> tezcatlipoca:~$ rst2odt.py essai_txt2odt.txt essai_txt2odt.odt > > missing visit_raw > > missing depart_raw > > nico <at> tezcatlipoca:~$ > > > some greps helped me to figure out that these two messages come from > an exception (like NameValueError ?) but i don't know what's missing. It seems like the raw directives are missing in the odtwriter. > there are some visit_raw and depart_raw methods in the different .py > files. i didn't understand from the documentation that i had to install > anything more to use a "raw" directive. documentation tells that the > raw directive is enabled by default. The documentation is about the standard docutils, whereas odtwriter is a separate extension with its own documentation. > PS > i've run the alltests.py but didn't get any problem : Again, alltests.py only test what is in the standard distribution but not odtwriter. You might ask the helpfull odtwriter author D. Kuhlman to look into the problem. I assume (but did not test) that adding `visit_raw` and `depart_raw` methods that just pass to the odtwriter class might solve your problem (but of course not provide raw access to odtwriter output which is a more complicated task). Guenter |
From: Dave K. <dku...@re...> - 2008-02-27 01:01:21
|
G. Milde <milde <at> users.berlios.de> writes: > > You might ask the helpfull odtwriter author D. Kuhlman to look into the > problem. > > I assume (but did not test) that adding `visit_raw` and `depart_raw` > methods that just pass to the odtwriter class might solve your problem > (but of course not provide raw access to odtwriter output which is a more > complicated task). > OK. I'll try. But, I'm not sure I'll know what to do. Would someone actually try to pass through the "raw" XML code to be inserted into a ODF .odt file? Here is an example of what that might look like:: .. raw:: odt <text:list text:style-name="rststyle-bulletlist"> <text:list-item> <text:p text:style-name="rststyle-bulletitem"> Python does what you want it to do <text:span text:style-name="rststyle-emphasis"> most </text:span> of the time so that you only have to add extra characters <text:span text:style-name="rststyle-emphasis"> some </text:span> of the time. </text:p> </text:list-item> o o o Gack! Of course, you would have to remove all (most? some?) of the indentation and whitespace. Would someone really want to do that? Or, should I just add the visit_raw and depart_raw methods, but ignore any content. Basically, this is what odtwriter does now. It is printing out that "missing" warning message and ignoring the raw directive. - Dave |
From: G. M. <mi...@us...> - 2008-02-27 09:05:57
|
On 27.02.08, Dave Kuhlman wrote: > G. Milde <milde <at> users.berlios.de> writes: > > I assume (but did not test) that adding `visit_raw` and `depart_raw` > > methods that just pass to the odtwriter class might solve your problem > > (but of course not provide raw access to odtwriter output which is a more > > complicated task). > > > OK. I'll try. But, I'm not sure I'll know what to do. Would > someone actually try to pass through the "raw" XML code to be > inserted into a ODF .odt file? Here is an example of what that > might look like:: ... > Gack! > Would someone really want to do that? I do not assume that people want to hand-write odt xml (the way you will do with raw latex, say). However, the raw directive might come handy e.g. * with snippets produced by other programs or taken from an oo-produced file, a text input field, say:: .. raw:: odt <draw:control text:anchor-type="as-char" svg:y="-0.887cm" draw:z-index="1" draw:style-name="gr1" draw:text-style-name="P1" svg:width="4.026cm" svg:height="1.438cm" draw:control="control1"/> This might be especially useful with raw input of external files. * as an alternative to raw text in another output format:: .. raw:: latex \latex .. raw:: html odt LaTeX > Of course, you would have to remove all (most? some?) of the > indentation and whitespace. Correct formatting might indeed be a problem, as messing with the whitespace seems to corrupt an oo document. Is there documentation about formatting issues? > Or, should I just add the visit_raw and depart_raw methods, but > ignore any content. Basically, this is what odtwriter does now. It > is printing out that "missing" warning message and ignoring the raw > directive. I could imagine the raw directive to insert its content in a form that is accepted by oofice -- at least with plain text. Alternatively, it could output a more verbose warning, like .. warning:: Ignoring content of raw directive: < content here > There is currently no consensus on how to implement the raw directive for odtwriter, help welcome. Günter |
From: nico h <nh...@la...> - 2008-02-28 13:26:38
|
G. Milde <milde <at> users.berlios.de> writes: > > On 27.02.08, Dave Kuhlman wrote: > > OK. I'll try. But, I'm not sure I'll know what to do. Would > > someone actually try to pass through the "raw" XML code to be > > inserted into a ODF .odt file? Here is an example of what that > > might look like:: > ... > > Gack! > > > Would someone really want to do that? Well, what I'm exactly looking for - and I'm not sure that the raw directive *is* the solution - is how to produce automatically odt documents including mathematical objects. Maybe a new directive would be more appropriated : I don't know. I was just exploring the odtwriter to see what's possible, and as I found docutils directives related to LaTeX, I thought that it might be a possibility. I asked for help first because of the installation directories' problem, that I actually solved "myself". I thought the visit_raw and depart_raw messages were related to that problem. I'm sorry to have started this thread which finally includes two different topics :o/ So, the question now (for me) is to know whether this raw directive could help including mathematical formulas in the odt (independently from the other possibly uses of a raw odt directive, like puttin in external files as Günter has suggested). The mathematical objects that an odt contains are separate files written in a special "OpenOffice.org" MML. The user usually writes simplified code that is translated into this special OOo MML. It would be really cool to write something like : .. <directive_name>: {6} over {8} = {3} over {4} in the ReST document and get the fractions in the odt result :o) But well... maybe it's a huge project ?? Anyway, thanks a lot for all the answers ! Have a nice day, Bye Nicolas PS. a little bit more info about my project : it consists of producing automatically maths exercises with the whole answers. The aim is to provide pupils with as many training exercises as they want (I work as a math teacher in a poor & difficult part of the town and they ask for a lot of them and need a lot of them) and also to help other teachers & myself concentrating on more interesting & important problems than always preparing the same simple exercises... An in-line preview can be found here [fr] : http://mr.hainaux.net/?/G/ Though it's in french, you may select a radio button and press the "Telecharger" button just under to get examples of what the soft produces. |
From: Alan G I. <ai...@am...> - 2008-02-28 15:55:17
|
On Thu, 28 Feb 2008, (UTC) nico h apparently wrote: > It would be really cool to write something like : > .. <directive_name>: > {6} over {8} = {3} over {4} Better yet, do you know about <URL:http://docutils.sourceforge.net/sandbox/jensj/latex_math/tools/rst2mathml.py>? Can this be adapted for the ODT writer? I have no clue. Cheers, Alan Isaac |