Re: python and open office

2016-08-01 Thread Lawrence D’Oliveiro
On Thursday, July 28, 2016 at 4:29:34 AM UTC+12, Crane Ugly wrote:

> I try to create some scripts that will help me to open and manipulate
> OpenOffice documents.

Have you looked at odfpy ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and open office

2016-07-27 Thread Leonid Shanin
I use LibreOffice. Yes, it looks like I have to switch to Python 3 in this case.
I'll try v.3 then
Thank you
Leonid



> On 27-07-2016, at 21:01, Terry Reedy  wrote:
> 
> On 7/27/2016 12:37 PM, Chris Kaynor wrote:
>> def __init__(self, name: str):
>> 
>> That "name: str" syntax is called function annotations, and was added in
>> Python 3, and you are trying to use the module in Python 2.7.
>> 
>> There may be another variation of the module compatible with Python 2, or
>> you'll need to upgrade your Python to a version of Python 3.
>> 
>> Chris
>> 
>> On Wed, Jul 27, 2016 at 9:28 AM, Crane Ugly  wrote:
>> 
>>> I try to create some scripts that will help me to open and manipulate
>>> OpenOffice documents. Calc in particular. But I have some problems finding
>>> right packages or libraries that offer such interface.
>>> So far I was trying uno and unotools but the first step is to import them
>>> failed. Here is the output:
>>> 
>>> UNO tools are installed:
>>> $ pip list | grep uno
>>> uno (0.3.3)
>>> unotools (0.3.3)
>>> 
>>> Try to import them:
>>> $ python
>>> Python 2.7.12 (default, Jun 29 2016, 12:53:15)
>>> [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
>>> Type "help", "copyright", "credits" or "license" for more information.
>> import uno
>> import unotools
>>> Traceback (most recent call last):
>>>  File "", line 1, in 
>>>  File
>>> "/Volumes/home/lshanin/Dropbox/Python/ve/accounting/lib/python2.7/site-packages/unotools/__init__.py",
>>> line 16
>>>def __init__(self, name: str):
>>>   ^
>>> SyntaxError: invalid syntax
>> 
>>> 
>>> I would appreciate is somebody help me to find what is wrong with untools
>>> package.
>>> Or point me to some other available libraries. I expect to work with
>>> OpenOffice (LibreOffice) files only not with MS Excel files.
> 
> Are you working with OpenOffice or LibreOffice?  There are *different 
> programs*.  Last I know, current LibreOffice comes with python 3.3.3 in its 
> program directory and you need at least Python 3.3.3 for its UNO bridge, as 
> it used the FSR unicode representation introduced in 3.3.
> 
> -- 
> Terry Jan Reedy
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and open office

2016-07-27 Thread Terry Reedy

On 7/27/2016 12:37 PM, Chris Kaynor wrote:

def __init__(self, name: str):

That "name: str" syntax is called function annotations, and was added in
Python 3, and you are trying to use the module in Python 2.7.

There may be another variation of the module compatible with Python 2, or
you'll need to upgrade your Python to a version of Python 3.

Chris

On Wed, Jul 27, 2016 at 9:28 AM, Crane Ugly  wrote:


I try to create some scripts that will help me to open and manipulate
OpenOffice documents. Calc in particular. But I have some problems finding
right packages or libraries that offer such interface.
So far I was trying uno and unotools but the first step is to import them
failed. Here is the output:

UNO tools are installed:
$ pip list | grep uno
uno (0.3.3)
unotools (0.3.3)

Try to import them:
$ python
Python 2.7.12 (default, Jun 29 2016, 12:53:15)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import uno
import unotools

Traceback (most recent call last):
  File "", line 1, in 
  File
"/Volumes/home/lshanin/Dropbox/Python/ve/accounting/lib/python2.7/site-packages/unotools/__init__.py",
line 16
def __init__(self, name: str):
   ^
SyntaxError: invalid syntax




I would appreciate is somebody help me to find what is wrong with untools
package.
Or point me to some other available libraries. I expect to work with
OpenOffice (LibreOffice) files only not with MS Excel files.


Are you working with OpenOffice or LibreOffice?  There are *different 
programs*.  Last I know, current LibreOffice comes with python 3.3.3 in 
its program directory and you need at least Python 3.3.3 for its UNO 
bridge, as it used the FSR unicode representation introduced in 3.3.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: python and open office

2016-07-27 Thread Chris Kaynor
def __init__(self, name: str):

That "name: str" syntax is called function annotations, and was added in
Python 3, and you are trying to use the module in Python 2.7.

There may be another variation of the module compatible with Python 2, or
you'll need to upgrade your Python to a version of Python 3.

Chris

On Wed, Jul 27, 2016 at 9:28 AM, Crane Ugly  wrote:

> I try to create some scripts that will help me to open and manipulate
> OpenOffice documents. Calc in particular. But I have some problems finding
> right packages or libraries that offer such interface.
> So far I was trying uno and unotools but the first step is to import them
> failed. Here is the output:
>
> UNO tools are installed:
> $ pip list | grep uno
> uno (0.3.3)
> unotools (0.3.3)
>
> Try to import them:
> $ python
> Python 2.7.12 (default, Jun 29 2016, 12:53:15)
> [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import uno
> >>> import unotools
> Traceback (most recent call last):
>   File "", line 1, in 
>   File
> "/Volumes/home/lshanin/Dropbox/Python/ve/accounting/lib/python2.7/site-packages/unotools/__init__.py",
> line 16
> def __init__(self, name: str):
>^
> SyntaxError: invalid syntax
> >>>
>
> I would appreciate is somebody help me to find what is wrong with untools
> package.
> Or point me to some other available libraries. I expect to work with
> OpenOffice (LibreOffice) files only not with MS Excel files.
>
> Regards
> Leonid
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-19 Thread Hartmut Goebel

Terry Reedy schrieb:

Hartmut Goebel wrote:



The API docs are a bit hidden on the webpage. Here is the link:



I wrote my comment *after* looking at the above, which I found easily 
enough.  After 7 pages of (helpful) explanatory text, there follow 88 
pages with hundreds of entries like this:


[...]

Well, I wrote my comment *before* looking at the API docs. Your are 
absolutely right: It is not helpful.



Additionally teh ODF sepcs may help:



v1.0 is the adopted international (ISO/IEC) standard.


Specs for ODF 1.0 are available the oasis-open.org, too. So if you want 
to keep close the the ISO standard you surely are better off using 1.0. 
Alternativly you may use the 1.1 docs and skim the appendix about changes.


Regards
H. Goebel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-18 Thread David Boddie
On Wednesday 17 September 2008 21:59, Terry Reedy wrote:
> Hartmut Goebel wrote:
>> Terry Reedy schrieb:
>> 
>> The API docs are a bit hidden on the webpage. Here is the link:
>> 
> 
> I wrote my comment *after* looking at the above, which I found easily
> enough.  After 7 pages of (helpful) explanatory text, there follow 88
> pages with hundreds of entries like this:

[...]

> which are translated to a more readable form from the Relax-NG schema
> (formal specs) in the standard.  But I have no idea what a Ruby property
> is in this context.  It would be much like reading the grammar entries
> in the Python Reference without the explanatory text that follows.

I started using odfpy for a project, and I found that I spent a lot of time
flicking back and forth in the API manual and cross-referencing it with the 
specification. The simple examples were useful enough to get started with,
but I could have used more information about how to use certain classes
and what elements and attributes they required.

I also wanted to add equations to the documents I was producing and that
requires some knowledge of MathML.

Certainly, it's not a very high level API for documentation creation - you
need to know something about the format to be able to construct documents.

David
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-17 Thread Terry Reedy

Hartmut Goebel wrote:

Terry Reedy schrieb:

One way to learn the meaning of some of the numerous attributes and 
values is to create a file with the wanted features with OOo, save, 
unzip, and examine the xml to see which tags are used for which features.


The API docs are a bit hidden on the webpage. Here is the link:



I wrote my comment *after* looking at the above, which I found easily 
enough.  After 7 pages of (helpful) explanatory text, there follow 88 
pages with hundreds of entries like this:


5.13.30 style.RubyProperties
Requires the following attributes: No attribute is required.
Allows the following attributes: rubyalign, rubyposition.
These elements contain style.RubyProperties: style.DefaultStyle, 
style.Style.

The following elements occur in style.RubyProperties: No element is allowed.

which are translated to a more readable form from the Relax-NG schema 
(formal specs) in the standard.  But I have no idea what a Ruby property 
is in this context.  It would be much like reading the grammar entries 
in the Python Reference without the explanatory text that follows.



Additionally teh ODF sepcs may help:



v1.0 is the adopted international (ISO/IEC) standard.
I did not notice whether odfpy supports the 1.1 extensitons, but since 
it does appear that OOo now uses them, I will presume so.


This does help.  It has more explanatory material.
"5.4 Ruby
A ruby is additional text that is displayed above or below some base 
text. The purpose of ruby is to annotate the base text or provide 
information about its pronunciation.


tjr

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-17 Thread Hartmut Goebel

Terry Reedy schrieb:

One way to learn the meaning of some of the numerous attributes and 
values is to create a file with the wanted features with OOo, save, 
unzip, and examine the xml to see which tags are used for which features.


The API docs are a bit hidden on the webpage. Here is the link:


Additionally teh ODF sepcs may help:


Regards
H. Goebel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-16 Thread Terry Reedy

Hartmut Goebel wrote:

As I thought everybody already knows, ODF is simply a Zip-File 
containing some XML files.


I thought it just *was* xml.  But examination with notepad showed 
otherwise.


> So there is no need to use OOo for handling

the files.

So odfpy seams to be the best way to to this.


Since odfpy automatically handles combining the at-least-4 xml files 
into one coherent class on loading, and putting the various properties 
into the proper xml files on saving, this looks pretty straightforward. 
 Thanks for the reference.


One way to learn the meaning of some of the numerous attributes and 
values is to create a file with the wanted features with OOo, save, 
unzip, and examine the xml to see which tags are used for which features.



 You may also want to check

OOopy .


I will glance at that too.


If you are going to interact with OOo, you may want to try out




--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-16 Thread Hartmut Goebel

Peter Georgeson schrieb:


I can confirm that unfortunately, the PyUNO interface presently
(OpenOffice 2.4) is built with Python 2.3... so to use the UNO
interface from Python you have to write a separate script to run in
the OpenOffice Python 2.3 environment.


This may be true for Windows. On Linux - at least for Mandriva --, OOo 
is already integrated with Python 2.5.


--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-16 Thread Hartmut Goebel

Marco Bizzarri schrieb:

On Wed, Sep 10, 2008 at 10:04 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:

Hello,

I would like to create and manipulate Open Office documents using Python.  I

[...]

Is there someone here who can help me out, or is there an appropriate
mailing list for me to join?


Ciao, Greg.

you should check with the openoffice.org mailing list; I think what
you are looking for is the api mailing list for openoffice; you could
try to get the OpenOffice.org developers guide and the SDK, and check
it (but it is not a little work)


If want to create documents, there is no nead to fight with OOo and UNO. 
As I thought everybody already knows, ODF is simply a Zip-File 
containing some XML files. So there is no need to use OOo for handling 
the files.


So odfpy seams to be the best way to to this. You may also want to check 
OOopy .


If you are going to interact with OOo, you may want to try out


--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-12 Thread Gary Herron

Greg Lindstrom wrote:

Hello,

I would like to create and manipulate Open Office documents using 
Python.  I have found then UNO Python page and odfpy modules which 
seem to be exactly what I need.  The odfpy manual is, to me, a 
confusing list of objects and methods (it's an impressive list!), but 
does not have much in the way of how to use them.  For example, I can 
open a spreadsheet and create new pages (there's a nice example near 
the back of the manual) but I can't figure out how to open an existing 
spreadsheet and list the names of the individual sheets ("tabs").


I have written an application that access Microsoft Excel and creates 
reports for work, but would like to create an Open Source version 
using Open Office and release it to the community (and maybe get a 
talk at PyCon :-).


Is there someone here who can help me out, or is there an appropriate 
mailing list for me to join? 


Thanks

--greg


--
http://mail.python.org/mailman/listinfo/python-list


Here's a snippet of code I use to open a spreadsheet (given as a file 
path name), and compute and return the list of sheets it contains.  It 
connects to an existing OpenOffice if possible, otherwise it starts 
OpenOffice and waits for it to accept a connection.




def OpenSS(path):
   localContext = uno.getComponentContext()
   resolver = localContext.ServiceManager.createInstanceWithContext(
   'com.sun.star.bridge.UnoUrlResolver', localContext )

   
resolveArg='uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext'


   # Conect to running OO;  First, starting OO if necessary;
   try:
   ctx = resolver.resolve(resolveArg)
   except NoConnectException:
   os.system("ooffice '-accept=socket,host=localhost,port=2002;urp;'&")
   while 1:
   print '  waiting for OpenOffice'
   time.sleep(1)
   try:
   ctx = resolver.resolve(resolveArg)
   break
   except NoConnectException:
   pass
   smgr = ctx.ServiceManager
   desktop = smgr.createInstanceWithContext( 
'com.sun.star.frame.Desktop', ctx)


   url = 'file://' + path
   component = desktop.loadComponentFromURL(url, '_default', 0, ())
   sheets = [component.getSheets().getByIndex(i)
 for i in range(component.getSheets().getCount())]
   return sheets


Hope this helps,

Gary Herro


--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-11 Thread Marco Bizzarri
Greg, as an addition to what I already said to you, you can consider
taking a look at oood from ERP5 project

http://wiki.erp5.org/HowToUseOood

OOOd (openoffice.org daemon) runs openoffice behind the scene, and
allows you to interact with it via XML-RPC; it should be quite robust,
since it is actively mantained and used in a big software project.
And, also, it should be quite easy to extend in order to have your
custom functions run via XML-RPC.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-11 Thread Peter Georgeson
On Sep 11, 7:04 am, "Colin J. Williams" <[EMAIL PROTECTED]> wrote:
> Marco Bizzarri wrote:
> > On Wed, Sep 10, 2008 at 10:04 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:
> >> Hello,
>
> >> I would like to create and manipulate Open Office documents using Python.  
> >> I
> >> have found then UNO Python page and odfpy modules which seem to be exactly
> >> what I need.  The odfpy manual is, to me, a confusing list of objects and
> >> methods (it's an impressive list!), but does not have much in the way of 
> >> how
> >> to use them.  For example, I can open a spreadsheet and create new pages
> >> (there's a nice example near the back of the manual) but I can't figure out
> >> how to open an existing spreadsheet and list the names of the individual
> >> sheets ("tabs").
>
> >> I have written an application that access Microsoft Excel and creates
> >> reports for work, but would like to create an Open Source version using 
> >> Open
> >> Office and release it to the community (and maybe get a talk at PyCon :-).
>
> >> Is there someone here who can help me out, or is there an appropriate
> >> mailing list for me to join?
>
> > Ciao, Greg.
>
> > you should check with the openoffice.org mailing list; I think what
> > you are looking for is the api mailing list for openoffice; you could
> > try to get the OpenOffice.org developers guide and the SDK, and check
> > it (but it is not a little work)
>
> > Regards
> > Marco
>
> >> Thanks
>
> >> --greg
>
> >> --
> >>http://mail.python.org/mailman/listinfo/python-list
>
> Greg,
>
> If you follow this up, I hope that you
> will post info to c.l.p
> and let us know whether the UNO
> interface is Python 2.5 compatible.
>
> The last time I looked it was set for
> 2.3 or 2.4.
>
> Colin W


I've recently been working on interfacing with OpenOffice via UNO with
Python.

I can confirm that unfortunately, the PyUNO interface presently
(OpenOffice 2.4) is built with Python 2.3... so to use the UNO
interface from Python you have to write a separate script to run in
the OpenOffice Python 2.3 environment.

Apparently someone is working on rebuilding the PyUNO library for
Python 2.5 but there's no timeframe for when that might be included
with the OpenOffice distribution.

You could try building PyUNO with Python 2.5 yourself, I'm sure I came
across instructions somewhere on the OpenOffice developer website...

I've not used odfpy so don't know how it compares in terms of degree
of difficulty to UNO.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-10 Thread Colin J. Williams

Marco Bizzarri wrote:

On Wed, Sep 10, 2008 at 10:04 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:

Hello,

I would like to create and manipulate Open Office documents using Python.  I
have found then UNO Python page and odfpy modules which seem to be exactly
what I need.  The odfpy manual is, to me, a confusing list of objects and
methods (it's an impressive list!), but does not have much in the way of how
to use them.  For example, I can open a spreadsheet and create new pages
(there's a nice example near the back of the manual) but I can't figure out
how to open an existing spreadsheet and list the names of the individual
sheets ("tabs").

I have written an application that access Microsoft Excel and creates
reports for work, but would like to create an Open Source version using Open
Office and release it to the community (and maybe get a talk at PyCon :-).

Is there someone here who can help me out, or is there an appropriate
mailing list for me to join?


Ciao, Greg.

you should check with the openoffice.org mailing list; I think what
you are looking for is the api mailing list for openoffice; you could
try to get the OpenOffice.org developers guide and the SDK, and check
it (but it is not a little work)

Regards
Marco



Thanks

--greg

--
http://mail.python.org/mailman/listinfo/python-list






Greg,

If you follow this up, I hope that you 
will post info to c.l.p
and let us know whether the UNO 
interface is Python 2.5 compatible.


The last time I looked it was set for 
2.3 or 2.4.


Colin W
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-10 Thread Marco Bizzarri
On Wed, Sep 10, 2008 at 10:04 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I would like to create and manipulate Open Office documents using Python.  I
> have found then UNO Python page and odfpy modules which seem to be exactly
> what I need.  The odfpy manual is, to me, a confusing list of objects and
> methods (it's an impressive list!), but does not have much in the way of how
> to use them.  For example, I can open a spreadsheet and create new pages
> (there's a nice example near the back of the manual) but I can't figure out
> how to open an existing spreadsheet and list the names of the individual
> sheets ("tabs").
>
> I have written an application that access Microsoft Excel and creates
> reports for work, but would like to create an Open Source version using Open
> Office and release it to the community (and maybe get a talk at PyCon :-).
>
> Is there someone here who can help me out, or is there an appropriate
> mailing list for me to join?

Ciao, Greg.

you should check with the openoffice.org mailing list; I think what
you are looking for is the api mailing list for openoffice; you could
try to get the OpenOffice.org developers guide and the SDK, and check
it (but it is not a little work)

Regards
Marco


> Thanks
>
> --greg
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list