![]() |
#541 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
If you are talking about the this action, the answer is yes, but you need to modify the action to change the chain vars based on your choice.
But a better approach to this is to add a Chain Vars action to the top of your chain, add a variable called 'myvar' and check the "runtime option". Now whenever you run a chain you will have a dialog asking you to specify the value for 'myvar'. You can set conditions on the following action(s) based on the value of 'myvar'. For example: Template: Code:
program: globals(myvar) Comparison: = Condition Value: 1 You can replace 1 with whatever value you choose at runtime. You can also set multiple variables at runtime if you want. |
![]() |
![]() |
![]() |
#542 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Chain Variations
The new chain variations feature is experimental and hidden by default. To enable it add the following tweak:
Code:
action_chains_experimental = True Code:
program: add_chain_variant('first variant','argument1'); add_chain_variant('second variant','argument2', 'submenu1', 'minus.png'); The example above passes static arguments to the add_chain_variant(). You can do the same thing by simply copying the chain and modifying each copy to do what you want. The real value of this feature is that you can use the template language to calculate dynamic values and pass them as arguments. e.g. lists created by set_persistent_vars(). Each time you add a new list, a menu entry can be added for it automatically. And if a list is deleted, its menu entry should be remove automatically as well. You can think of this like the "add to list" in the Reading List plugin where you have a menu entry for each list. The same can be done for the Action Chains. e.g. If you have multiple lists stored in persistent storage using the set_persistent_vars() function, you can have a template replicating the chain for each of those lists. The add_chain_variant() take 2 mandatory arguments + 2 optional arguments:
Finally, you can use the same function to add a separator between the variants: Code:
program: add_chain_variant('separator',''); Last edited by capink; 05-13-2021 at 10:24 AM. |
![]() |
![]() |
![]() |
#543 |
Enthusiast
![]() Posts: 34
Karma: 10
Join Date: Aug 2014
Device: Kindle Paperwhite, Kindle Fire HD 8, Microsoft Surface Go 3
|
Latest update appears to have broken TemplateBox.
I have the following line in an action chain module: from calibre_plugins.action_chains.templates import TemplateBox, check_template, get_metadata_object Getting the following error after the latest plugin and Cailbre updates: calibre, version 5.16.0 ERROR: Invalid Python code: The code you created is not valid Python code, with error: cannot import name 'TemplateBox' from 'calibre_plugins.action_chains.templates' (C:\Users\xxxxxxx\AppData\Roaming\calibre\plugins\ Action Chains.zip/templates/__init__.py) Is this something I can fix, or do I need to wait for an update to ActionsChains plugin or Calibre? |
![]() |
![]() |
![]() |
#544 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
from calibre_plugins.action_chains.templates.dialogs import TemplateBox from calibre_plugins.action_chains.templates import check_template, get_metadata_object |
|
![]() |
![]() |
![]() |
#545 | |
Enthusiast
![]() Posts: 34
Karma: 10
Join Date: Aug 2014
Device: Kindle Paperwhite, Kindle Fire HD 8, Microsoft Surface Go 3
|
Quote:
Are these types of changes documented somewhere? |
|
![]() |
![]() |
![]() |
#546 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
I did post a custom action here that depends on this particular import, but this action has been included in the plugin as a builtin action called "Search Using Templates". If that was the action you are using, you should move to the builtin version. |
|
![]() |
![]() |
![]() |
#547 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,976
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Can an action have more than one condition?
I switched my "View" action conditional to program: view_manager_last_view() != Physical Books, but I'd like to also keep the {formats} != PAPERBOOK conditional. Last edited by ownedbycats; 04-20-2021 at 10:44 PM. |
![]() |
![]() |
![]() |
#548 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Yes. See below.
Quote:
|
|
![]() |
![]() |
![]() |
#549 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,976
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
OK that's good. I will try to figure that out.
![]() |
![]() |
![]() |
![]() |
#550 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
template:
Code:
program: $formats != 'PAPERBOOK' && view_manager_last_view() != 'Physical Books' Comparison: = Condition Value: 1 |
![]() |
![]() |
![]() |
#551 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,976
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works.
![]() |
![]() |
![]() |
![]() |
#552 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Version 1.8.0
Update: New template functions: sanitize_path(), cover_path(). Update: Events: New "Calibre Initialized" Event. Update: Experimental: New chain variation feature. Update: Open With: Template GPM can be used for command arguments. Fix: Crash if you delete a row from the actions table with editor open but no action selected. You can read more about chain variations here. |
![]() |
![]() |
![]() |
#553 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,976
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I think I know what cover_path() is, but what does sanitize_path() do?
|
![]() |
![]() |
![]() |
#554 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
You can see how both are used in the chain posted here. If you want to save a file using the plugin based on a template like {authors}\{title}, there are chances they contain illegal characters not supported by OS for filenames. sanitize_path() removes these illegal characters.
|
![]() |
![]() |
![]() |
#555 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,976
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That's good. I once had a cross-platform program mistakenly save a file with a colon, which is illegal in Windows. I had to use a Linux boot disk to get rid of the damn thing.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Editor Plugin] Editor Chains | capink | Plugins | 106 | 06-17-2025 05:36 PM |
Action Chains Resources | capink | Plugins | 77 | 06-16-2025 12:45 PM |
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 03:15 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 05:25 AM |