Bug 429262 - Import Python Plugins doesn't import all action files
Summary: Import Python Plugins doesn't import all action files
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 4.4.1
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Rebecca Breu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-17 20:49 UTC by Tiar
Modified: 2020-11-20 08:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Three slots plugin (as an example/test file) (4.93 KB, application/zip)
2020-11-17 20:49 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2020-11-17 20:49:55 UTC
Created attachment 133408 [details]
Three slots plugin (as an example/test file)

SUMMARY
Import Python Plugins plugin doesn't import all action files; it only import the one that contains an action which name is exactly the same as the plugin. It is a problem with those p0lugins that have multiple actions but those actions don't activate the plugin itself but do something else. For example ThreeSlots plugin https://github.com/DarkDefender/threeslots contains an action file with three actions: "activate_slot_1", "..._2", "..._3", and none of those actions are called the same way as the main plugin, so action file will be skipped, even though it's necessary for the plugin to work correctly.

NOTE: there are more plugins like this; all "shortcuts-based" plugins have actions files and the requirement that it needs to contain an action with the same name as the name of the plugin is unclear and, in my opinion, uncalled for.

STEPS TO REPRODUCE
1. Download ThreeSlots plugin.
2. Use Import Python Plugin to import it.

OBSERVED RESULT
There are no shortcuts to assign.
If you put the action files in [resource folder]/actions/, you will get the shortcuts and it will work correctly.

EXPECTED RESULT
Import Python Plugin plugin imports all relevant action files.

NOTE
It looks like the plugin importer tries to be smart about it and be suitable to import multiple plugins at once. I don't think there is a need for that, most plugins come from github-like websites or just dropbox/gumroad websites in one zip per one plugin.


SOFTWARE/OS VERSIONS
Krita

 Version: 4.4.1
 Languages: en_US, en, en_US, en, en_US, en, pl_PL, pl, pl_PL, pl
 Hidpi: true

Qt

  Version (compiled): 5.12.9
  Version (loaded): 5.12.9
Comment 1 Halla Rempt 2020-11-17 21:01:16 UTC
Rebecca,

Could you please take a look? Thanks!
Comment 2 Rebecca Breu 2020-11-17 21:12:36 UTC
Sure!
Comment 3 Tiar 2020-11-17 21:26:43 UTC
The problem is in function "get_source_actionfile" in line 141 in plugins/python/plugin_importer/plugin_importer.py .

A bug/wish about the same plugin, might be easy to fix both at the same time: bug 429265 .

Thanks for checking this out, I think fixing it will improve the custom Python plugins workflow a lot :) Much less scary for users than manual importing.
Comment 4 Bug Janitor Service 2020-11-19 19:18:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/596
Comment 5 Halla Rempt 2020-11-20 08:28:28 UTC
Git commit 43d283baddf63f5dd0fda99e911aeb4f425fb5b4 by Boudewijn Rempt, on behalf of Rebecca Breu.
Committed on 20/11/2020 at 08:28.
Pushed by rempt into branch 'master'.

Make Plugin Importer more flexible regarding actions

Don't make assumptions about the contents of action files — just import.

M  +2    -2    dev-tools/python/dev-requirements.txt
M  +3    -11   plugins/python/plugin_importer/plugin_importer.py
D  +0    -1    plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo.action
A  +19   -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo.action
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo.desktop [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo.desktop - 100% similarity]
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo/__init__.py [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo/__init__.py - 100% similarity]
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo/foo.py [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo/foo.py - 100% similarity]
M  +19   -13   plugins/python/plugin_importer/tests/test_plugin_importer.py

https://invent.kde.org/graphics/krita/commit/43d283baddf63f5dd0fda99e911aeb4f425fb5b4
Comment 6 Halla Rempt 2020-11-20 08:28:54 UTC
Git commit dae45839b43d874a9fc31c231ff8a6865a3e6b79 by Boudewijn Rempt, on behalf of Rebecca Breu.
Committed on 20/11/2020 at 08:28.
Pushed by rempt into branch 'krita/4.3'.

Make Plugin Importer more flexible regarding actions

Don't make assumptions about the contents of action files — just import.
(cherry picked from commit 43d283baddf63f5dd0fda99e911aeb4f425fb5b4)

M  +2    -2    dev-tools/python/dev-requirements.txt
M  +3    -11   plugins/python/plugin_importer/plugin_importer.py
D  +0    -1    plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo.action
A  +19   -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo.action
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo.desktop [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo.desktop - 100% similarity]
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo/__init__.py [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo/__init__.py - 100% similarity]
R  +0    -0    plugins/python/plugin_importer/tests/fixtures/success_different_action_name/plugin/foo/foo.py [from: plugins/python/plugin_importer/tests/fixtures/fail_unparsable_action_file/plugin/foo/foo.py - 100% similarity]
M  +19   -13   plugins/python/plugin_importer/tests/test_plugin_importer.py

https://invent.kde.org/graphics/krita/commit/dae45839b43d874a9fc31c231ff8a6865a3e6b79