APSO - Alternative Script Organizer for Python
Based on an original script from Hanya, APSO will install a macro organizer dedicated to python scripts.
latest release: 2024-07-29 19:04:58
Description
APSO is compatible with OpenOffice until version 1.3.2
Based on an original script from Hanya, APSO is an extension that will install a macro organizer dedicated to python scripts.
Prerequisite
On some systems (like Ubuntu), the python script provider for LibreOffice is only available as a separate package (see here).
Features
- localisation (by now EN, DE, FR, IT, HU thanks to Tibor Kovács, NL thanks to Dick Groskamp, ES thanks to Francisco Gracia, JA thanks to Nogajun and PT thanks to Rafael Lima)
- embedding scripts in or extracting them from documents
- binding the extension with one's favorite code editor (thanks to another script from Hanya, see Options below)
- quick edition of embedded scripts (but only in the context of the APSO extension, be careful here)
- integrated gui debugger
- interactive python interpreter
- automatic update once installed
- context menu for quick access to node actions (from 1.3.0)
- [beta] package manager (thanks to Jurassik Pork)
Limitations
- Embedding python scripts in flat xml document does not work (see issue #49).
How to use it
APSO adds a new element Organize python scripts under menu Tools/Macros with default shortcut Alt+Shift+F11:
This new item or shortcut opens a dialog box that lists all python scripts and provides various actions:
The Execute button launches the selected macro. Actions available under Menu button change according to the selection:
- create module or library if selection is a container (My Macros, Office Macros or document)
- Edit, rename, delete a module or library
- Embed module from application (My Macros or Office Macros) into current document
- Substitute an embedded module with an external file
- Export an embedded module
Helpers
APSO comes with a small library apso_utils that contains some helpers for debugging purpose during macro writing. These helpers are four functions named msgbox, xray, mri and console and can be imported by a classic import statement like from apso_utils import msgbox
function | description |
msgbox |
Like the oobasic build-in function msgbox, but simplified as only intended for quick debugging. Signature: msgbox(message, title='Message', boxtype='message', buttons=1, win=None) |
xray |
Launches the introspection tool Xray by Bernard Marcelly (must be installed first) Signature: xray(obj) |
mri |
Launches the introspection tool MRI by Hanya (must be installed first) Signature: mri(target) |
console |
Emulates, as close as possible, the python interactive shell. What one can do with such a tool: Signature: console(**kwargs), where optional kwargs are intended to overwrite default gui values (BACKGROUND, FOREGROUND...) or to pass caller's locales and/or globals to the console context. |
Example
from apso_utils import console, msgbox, mri, xray
def testhelpers():
# console()
# console(BACKGROUND=0x0, FOREGROUND=0xFFFFFF)
loc = locals()
loc.update(globals())
console(loc=loc)
doc = XSCRIPTCONTEXT.getDocument()
# xray(doc)
msgbox(doc.Title)
mri(doc)
Only the console macro is accessible outside an APSO instance. If someone wants to import the module apso_utils independently of APSO, he has to force that instanciation:
def entryfunc(event=None):
ctx = XSCRIPTCONTEXT.getComponentContext()
ctx.ServiceManager.createInstance("apso.python.script.organizer.impl")
# now we can import apso_utils library
from apso_utils import console
console()
Integreted debugger
The debugger can be launched from the Apso "Menu" button when a function is selected in the main window.
Once the debugger opened, one can execute the code step by step, enter any called function, return to the caller, etc.
Break points are not supported, but you can jump ahead by double clicking any line below the current one within the same function.
You can check any caller state and scope by double clicking it in the "Stack" window (bottom left). If you have MRI or Xray installed, you can inspect any UNO variables by double clicking it in the "Scope" window (bottom right).
When you open a console window from the tool bar, the global and local scope will be automatically loaded.
If you edit the script while the debugger is running, changes will be taken in account after clicking "Restart".
The debugger uses the font name and height defined for the Basic IDE.
The debugger is still not fully localised
APSO Options
The extension option page is available under Tools -> Extension Manager -> APSO -> Options.
By default, APSO uses the system defined editor. To edit scripts with a specific editor, provide the executable full path in the "Editor" field. Some MacOS editors seem to behave differently; if you encounter any problem, please refer to this post in the French OpenOffice/LibreOffice forum.
To allow the opening at a given line and column offset when relevant, enter in the "Options" field the command line syntax corresponding to the choosen editor, using the placeholders {FILENAME}, {ROW} and {COL} (they will be replaced in due time).
Example for Emacs: +{ROW}:{COL} {FILENAME}.
Example for Sublime Text: {FILENAME}:{ROW}:{COL}.
A third option allows specifying the default content on any new module.
A fourth option allow to activate the experimental pip package manager (enlarge the option dialog if that option is not visible at first).
Three advanced options are available in the Expert configuration section of LibreOffice (menu Tools -> Options -> LibreOffice -> Advanced):
- SaveLastScript, if true, keeps history of the last run script (added in 1.3.0);
- SaveTreeState, if true, keeps history of all expanded nodes on last run script (added in 1.3.0);
- UnloadChildOnCollapse, if true, collapses the requested node and all its children; if false, collapses only the requested node (added in 1.3.0);
Homepage: https://gitlab.com/jmzambon/apso
Repository: https://gitlab.com/jmzambon/apso
Release | Description | Compatibility | Operating Systems | License | Release notes | Updated | |
---|---|---|---|---|---|---|---|
v1.4.2 | Apso with pip package manager | 7.3 | Linux, Windows, macOS | AL | The pip package manager is only available once activated form the extension option dialog. This feature was proposed and developed by Jurassik Pork, whom I would like to thank warmly. Important note. The package manager installs packages (including pip) in the current user's site-packages directory of the current user (see from site import USER_SITE). This directory is outside the LibreOffice user profile. In other words, the installed packages will not be automatically removed when uninstalling LibreOffice. You access this manager by clicking on the last item in the APSO menu: Package manager. A package management window then opens: The Installation of pip button allows you to install pip if it is not already installed. An error message appears in the console text area of the window stating that pip is not installed if this is the case. The List Packages button allows you to display packages that are already installed. We then see the name of the packages as well as the installed version. The Install Package button allows you to install the module that is indicated in the Package field. For example, to install the numpy package, type numpy in the Package field. You can also indicate the version of the package you want to install. For example to install version 1.15.4 of the numpy package you must type numpy==1.15.4 The Uninstall Package button allows you to uninstall the module that is indicated in the Package field. The OK button closes the Package Manager window. The Clear button clears the contents of the text console. |
2024-07-29 19:00:23 | Download |
v1.3.2 | New translation, enchancements and bug fixes | 3.4 | Linux, Windows, macOS | AL | [1.3.2] - Translate APSO to Portuguese, thanks to Rafael Lima [#33] - Add logging mode (bêta). - Fix error when history refers to an inactive document provider. - Code enhancements. [1.3.1] - [Debugger] Fix issue in selected default fixed font. [1.3.0] - Add context menu (issue #22). - Add two options to keep tree state and to collapse childs on parent collapsing (issue #23). WARNING: user upgrading from 1.2.x will have to re-enter his preferences in Apso option dialog. - Add shortcut Ctrl+Enter (Cmd+Enter on Mac) to collapse node, alongside with left arrow (compare with Enter/right arrow). - Add menu item icon. - Small fixes. |
2022-09-13 18:48:17 | Download |
v1.2.8 | Bug fix and small enhancement. | 3.4 | Linux, Windows, macOS | AL | - The console() method now retuns a reference to the console object, allowing to close programmaticaly the console window by invoking its enddialog() method (issue #21). - Fix issue #20 "LibreOffice freezes on some linux configurations". |
2021-06-10 22:19:04 | Download |
1.2.7 | Minor improvements | 3.4 | Linux, Windows, macOS | AL | Make node sorting locale aware. Minor improvements and bug fixes |
2021-05-08 15:04:18 | Download |
1.2.5 | Add Japanese language, thanks to Nogajun contribution. | 3.4 | Linux, Windows, macOS | AL | 2020-03-05 22:45:54 | external link | |
1.2.3 | Clean up debugger and apso_utils code. | 3.4 | Linux, Windows, macOS | AL | Fix a bug under OpenOffice, where splitter windows weren't properly closed on debug window closing, causing program crash. Other code clean up. |
2020-03-05 22:45:54 | external link |
1.1.4 | Code fixing and cleaning | 3.4 | Linux, Windows, macOS | AL | 2020-03-05 22:45:53 | external link | |
1.0.0 | First official release | 5.0 | Linux, Windows, macOS | AL | See main description page for more details. Tested on LibreOffice 5.x and OpenOffice 4.x. But should work on previous versions. |
2020-03-05 22:45:53 | external link |
1.2.4 | Add Spanish language | 4.4 | Linux, Windows, macOS | AL | Translated by Francisco Gracia. Thanks to him. Gracias a el. |
2020-03-05 22:45:52 | external link |
1.0.2 | Bug fixes | 4.0 | Linux, Windows, macOS | AL | Fix a bug where APSO was not able to launch from a database subdocument (base form, query wizard...). Fix some other small bugs. |
2020-03-05 22:45:52 | external link |
1.2.1 | New integrated debugger tool and minor bug fixes in module and library naming. | 3.4 | Linux, Windows, macOS | AL | The debugger can be launched from the Apso "Menu" button when a function is selected in the main window. Once the debuuger opened, one can execute the code step by step, enter any called function, return to the caller, etc. Break points are not supported, but you can jump ahead by double clicking any line below the current one within the same function. You can check any caller state and scope by double clicking it in the "Stack" window (bottom left). If you have MRI or Xray installed, you can inspect any UNO variables by double clicking it in the "Scope" window (bottom right). When you open a console window from the tool bar, the global and local scope will be automatically loaded. If you edit the script while the debugger is running, changes will be taken in account after clicking "Restart". The debugger uses the font name and height defined for the Basic IDE. The debugger is still not fully localised |
2020-03-05 22:45:51 | external link |
1.2.6.2 | Add custom content of any new module | 3.4 | Linux, Windows, macOS | AL | The default header lines, inserted at creation of a new module, can now be customized from the option dialog. This release also fixes a bug in the option dialog, where the "back" button had no effect, and translates to english remaining french argument names. It also fixes a bunch of non blocking errors, with the help of Mike Kaganski. |
2020-03-05 22:45:50 | external link |
1.1.2 | New console tool (see Menu button). Code clean up. |
4.0 | Linux, Windows, macOS | AL | 2020-03-05 22:45:50 | external link | |
1.2.0 | New integrated debugger tool and minor bug fixes in module and library naming. | 3.4 | Linux, Windows, macOS | AL | The debugger can be launched from the Apso "Menu" button when a function is selected in the main window. Once the debuuger opened, one can execute the code step by step, enter any called function, return to the caller, etc. Break points are not supported, but you can jump ahead by double clicking any line below the current one within the same function. You can check any caller state and scope by double clicking it in the "Stack" window (bottom left). If you have MRI or Xray installed, you can inspect any UNO variables by double clicking it in the "Scope" window (bottom right). When you open a console window from the tool bar, the global and local scope will be automatically loaded. If you edit the script while the debugger is running, changes will be taken in account after clicking "Restart". The debugger uses the font name and height defined for the Basic IDE. The debugger is still not fully localised |
2020-03-05 22:45:49 | external link |
1.2.2 | Minor bug fixes. | 3.4 | Linux, Windows, macOS | AL | Move exposed functions (by now just "console") to a dedicated folder, apart from apso_utils module (v1.2.2.0). Change call to Mri in debugger (v1.2.2.1). Fix two minor bugs: - XSCRIPTCONTEXT global variable is sometime inconsistent in the console (v1.2.2.0) - "console" function was no more available outside APSO (v1.2.2.0) ------------------- |
2020-03-05 22:45:49 | external link |
★ ★ ★ ☆ ☆
Post your review
You cannot post reviews until you have logged in. Login Here.
Reviews
Zafar Minhas Feb 5, 2024, 7:46 AM (11 months ago)
☆ ☆ ☆ ☆ ☆
1.3.2 works fine. However when i updated to 1.3.3 I get the following when trying to edit python code:
Traceback (most recent call last):
File "C:\Users\tminh\AppData\Roaming\LibreOffice\4\user\uno_packages\cache\uno_packages\lu1144ct9h4a.tmp_\apso.oxt\python\apso.py", line 926, in exec_edit
open_script(self.settings, url, lineno, 0)
File "C:\Users\tminh\AppData\Roaming\LibreOffice\4\user\uno_packages\cache\uno_packages\lu1144ct9h4a.tmp_\apso.oxt\python\apso.py", line 91, in open_script
opendefaulteditor(uno.fileUrlToSystemPath(url))
File "C:\Users\tminh\AppData\Roaming\LibreOffice\4\user\uno_packages\cache\uno_packages\lu1144ct9h4a.tmp_\apso.oxt\python\apso.py", line 102, in opendefaulteditor
sub_call(('xdg-open', filepath))
File "C:\Program Files\LibreOffice\program\python-core-3.8.18\lib\subprocess.py", line 340, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Program Files\LibreOffice\program\python-core-3.8.18\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\LibreOffice\program\python-core-3.8.18\lib\subprocess.py", line 1327, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Zafar Minhas Feb 5, 2024, 7:47 AM (11 months ago)
Here is my version:
Version: 24.2.0.3 (X86_64) / LibreOffice Community
Build ID: da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Paul Beyard Mar 4, 2023, 2:35 AM (22 months ago)
★ ★ ★ ☆ ☆
In 'My Macros' I created a library and inside that a Module and inside that some functions. I have discovered that I cannot 'import' the module and use the functions unless I completely close my database (.odb file) and reopen it, which is tedious. I use Geany to edit. Does anyone else see this behavior and know how to get APSO to save the code properly so that it can be used right away? Or is this not possible?
Jean-Marc Zambon Jul 12, 2023, 6:04 PM (18 months ago)
Hi,
External modules must be place in a forlder named "pythonpath" alongside the main module. This is a LibreOffice feature, not an Apso limitation.
If you modify an external module, it must be reloaded from the main code.
Jean-Marc Zambon Jul 12, 2023, 6:05 PM (18 months ago)
https://help.libreoffice.org/7.5/en-US/text/sbasic/python/python_import.html?&DbPAR=SHARED&System=UNIX
Marrou Bertrand Dec 14, 2022, 12:30 PM (2 years ago)
★ ☆ ☆ ☆ ☆
J'ai installé APSO sur libreoffice de ma distribution Linux Mageia.
Depuis, libreoffice plante au démarrage.
Je peux démarrer le "libre office start center" mais lorsque j'accède au menu Outils - Gestionnaire des extensions. Désintallation et réinstallation de LO n'a rien changé.
Je vais réinstaller Mageia !!!
Jean-Marc Zambon Jul 12, 2023, 6:01 PM (18 months ago)
Bonjour,
Ce n'est évidemment pas normal, mais difficile de vous aider sans avoir plus de détails.
Inutile de réinstaller Mageia, il suffit en principe juste de supprimer votre profil LibreOffice.
Jacob Wikner Nov 14, 2022, 10:00 PM (2 years ago)
★ ★ ☆ ☆ ☆
Is it supported by more recent versions of libreoffice and if so - how is it installed? (Ubuntu 22.10, Libreoffice 7.4.2.3)
Jean-Marc Zambon Jul 12, 2023, 5:59 PM (18 months ago)
It works fine with last 7.5 LibreOffice.
You install it from the Extension Manager, as any else extension (see https://help.libreoffice.org/7.5/en-US/text/shared/01/packagemanager.html#hd_id3895382).
Maurice Darr Oct 21, 2022, 2:26 PM (2 years ago)
☆ ☆ ☆ ☆ ☆
when I try to edit a python script all I get is a flash of a new command window trying to open and failing. Debug works fine and python shell work fine.
Is there a configuration step I am missing?
Jean-Marc Zambon Jul 12, 2023, 5:57 PM (18 months ago)
Hi Maurice,
Can you provide more info about your environment (LibO version, Apso version, OS...)?
And also how are defined your Apso options?
Leandro de Oliveira Sep 22, 2021, 8:48 PM (3 years ago)
★ ★ ★ ★ ★
It works fine. I use Notepad++ as my IDE for python programming, and when I click edit it opens right in Notepad++. Thanks for the authors!
LO v7.2.1.2 x64
Windows 7
Jean-Marc Zambon Jan 3, 2022, 4:24 PM (3 years ago)
Thanks a lot for your feedback :).
The Base Aug 26, 2021, 7:38 AM (3 years ago)
★ ★ ★ ★ ★
When using Apso 1.2.8. the standard HelloWorld gives me the following reference error https://imgbox.com/RkQTifNV Please advise howto proceed.
Jean-Marc Zambon Jan 3, 2022, 4:24 PM (3 years ago)
Hi The Base,
It works fine for me. Could you give more info about your environment (OS, LibO version, etc.).
Thanks.
Patrick Rippes Oct 2, 2020, 1:34 PM (4 years ago)
★ ★ ★ ★ ★
comment télécharger apso
jmzambon Nov 1, 2020, 5:58 PM (4 years ago)
Hi,
Just click on the first "External link" button in the release list above.
No one has commented on this page yet.
RSS feed for reviews on this page | RSS feed for all reviews