Description: With the advent of 6.2, two new Python scripts examples have been bundled with LibreOffice inside <install>/share/scripts/python folder. They lack: - Licensing header - SetCellColor.py - parcel-descriptor.xml translation file - SetCellColor.py They malfunction. They are not documented in local/online help. Steps to Reproduce: 1. Open <install>/Share/scripts/python folder 2. Check folder content 1. Select Tools-Macros-Run macro.. 2. Scroll the list and notice NamedRanges.py & SetCellColor.py are lacking a description within 'macro selector' dialog. Actual Results: With the advent of 6.2, two new Python scripts examples have been bundled with LibreOffice inside <install>/share/scripts/python folder. They lack: - Licensing header - SetCellColor.py - parcel-descriptor.xml translation file - SetCellColor.py They are not documented in local/online help. Both scripts should check for a valid active Calc document before processing: SetCellColor.py is raising an exception! Expected Results: There should be a parcel-descriptor file for SetCellColor.py SetCellColor.py should have a license header Both files should be documented in local/online help. Reproducible: Always User Profile Reset: No Additional Info: Categorized bug component is 'Documentation as I could not identify the appropriate one.
Source is https://opengrok.libreoffice.org/history/core/scripting/examples/python/SetCellColor.py
I have already made some improvements to the example python scripts, in the following commit: commit 5fb0e0f68bc9d37d43e0782b903919630852904c Improve example python code in scripting. * Modified the code to be more pythonic. * If "len(theString) == 0", then "not theString" evaluates to True. * "theString[0].isupper()" and "theString[1].isupper()" can be combined. * Remove unused imported string module * Wrap long lines * run autopep8 to prettify * ... Also, SetCellColor.py is updated to actually do something (instead of showing an exception), in the following patch in gerrit awaiting for review: https://gerrit.libreoffice.org/c/core/+/104720 By the way, what is a "parcel-descriptor file" and how can I create it?
Hi Kevin, Parcel descriptor files are .xml files that exhibit translatable script/macro descriptions when using " Tools - Macros - Run macro… " menu. You can find such examples in beanshell, java and javascript folders inside <INSTALLPATH>/Share/Scripts directory. Unfortunately Python script descriptions do not show up in my tests. This is most probably inherited from OOo. Providing this is fixed, I would happily document Python scripts examples in local/online help.
About parcel descriptor files, see also: https://wiki.openoffice.org/w/images/0/0a/DevelopersGuide_OOo3.1.0_18Scripting.odt
(In reply to Kevin Suo from comment #2) > showing an exception), in the following patch in gerrit awaiting for review: > https://gerrit.libreoffice.org/c/core/+/104720 You need to add reviewers in gerrit.
(In reply to sdc.blanco from comment #5) Yes I am aware of this. Currently we have much more important bugs to test - so this minor issue should be put behind and will come to this in a later day.
Alain Romedenne: I don't think the parcel descriptor files works with python macros. Could you try?
(In reply to Kevin Suo from comment #7) > Alain Romedenne: I don't think the parcel descriptor files works with python > macros. Could you try? I have tried already. Thanks for having tried your side as well
Basic and Python scripts deserve an enhancement request to permit macro descriptions in the 'Run macro' dialog. You can skip that point …
Created attachment 168585 [details] updated SetCellColor.py
Created attachment 168586 [details] updated NamedRanges.py These are the updated python examples which are also on gerrit for review. Others who do not have access to gerrit can also help to test. To test, place these two files in: <your_home_dir/.config/libreoffice/4/user/Scripts/python and then run from the Run Macros dialog > My Macros.
Kevin Suo committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/97d51446052acb5465c7ebe0ba3ce4d4570d25b0 tdf#128463: Make SetCellColor python example actually do sth It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Kevin Suo committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/8c9cc54bd7b6f3ba723d7a42ccc6a5372a80f970 tdf#128463: Rewrite NamedRanges.py to make it work when run from UI It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
The script is now updated on master. If you have time, you may update it on local/online help.
Nobody claimed the script was supposed to be usable except for a very specific demo purpose, from what is now https://github.com/CollaboraOnline/online/blob/master/loleaflet/html/framed.html (but back then was part of what used to be called "LibreOffice Online"). I am a bit sad that nobody bothered to ask the person who committed the script (me) what its purpose is when filing this bug. Now the script presumably no longer is usable from that demo thing, but oh well, whatever.
As for the "Both files should be documented" claim I disagree. They were not documented on purpose because they are not supposed to be usable in general. Doesn't the word "examples" give a strong hint that they are not supposed to be some bloody documented stable API etc?
Probably it would be best now to just remove these two scripts.
I wonder why the Apache part ("This file incorporates work covered by the following license notice") was added to the license blurb of NamedRanges.py in 8c9cc54bd7b6f3ba723d7a42ccc6a5372a80f970 ? As far as I recall, I created the script from scratch in e32b4c8a079e4b51b1028d2467b872ff5b8cdd3a . But if you Kevin have better information, that the script is based on something from OO.o, please say so.
Kevin Suo committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6b57cfb71a9546c32c03848751181b2db4f47176 tdf#128463: Revert the change to license information It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
(In reply to Tor Lillqvist from comment #15) > Nobody claimed the script was supposed to be usable Pretty well a guarantee for anything to do with python. Working examples are much better demonstrations.
I was confused why supplied examples didn't work. Examples now work well demonstrating functionality much better providing a framework for user experimentation. Thank you for the community effort.