Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 12-21-2021, 05:34 AM   #766
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,091
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
@ownedbycats: HYG
capink is online now   Reply With Quote
Old 12-27-2021, 05:24 PM   #767
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db().refresh()
I tried attaching this to my "switch view manager on VL tab click" chain to refresh a composite column. It gave me an error (LibraryDatabase is not callable). What did I do wrong?

Last edited by ownedbycats; 12-27-2021 at 05:29 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 12-27-2021, 05:30 PM   #768
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db().refresh()
I tried attaching this to my "switch view manager on VL tab click" chain to refresh a composite column. It gave me an error (LibraryDatabase is not callable). What did I do wrong?
This was me leading you astray again. See this post for more detail.
chaley is offline   Reply With Quote
Old 12-28-2021, 10:33 PM   #769
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have it working now and I posted in Action Chains scripts.

Another question:

Currently, the chain here halts the entire thing if I press 'no.' Is it possible to make it only apply to the next action in the chain?

Background:

Currently, I have two chains: "Send to Device" and "Send to Device + Add to TBR." They're identical except for a a single 'add to reading list' action. So instead of two chains, it makes sense to prompt for that one action. Putting it at the end works, but then that means I can't put my column re-sort module there.

Last edited by ownedbycats; 12-29-2021 at 12:15 AM.
ownedbycats is offline   Reply With Quote
Old 12-29-2021, 04:04 AM   #770
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,091
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
I have it working now and I posted in Action Chains scripts.

Another question:

Currently, the chain here halts the entire thing if I press 'no.' Is it possible to make it only apply to the next action in the chain?

Background:

Currently, I have two chains: "Send to Device" and "Send to Device + Add to TBR." They're identical except for a a single 'add to reading list' action. So instead of two chains, it makes sense to prompt for that one action. Putting it at the end works, but then that means I can't put my column re-sort module there.
You can use the chain variables action interactively (by checking the runtime box). It pops up a dialog where you where you set a value for the variable, you can then use the value to condition the action you want to run/skip.

Edit: A better approach is to use the Chain Variations feature which is designed for this kind of thing. It will alleviate the need to have a pop-up prompt, as it allows you to have multiple menu entries for the same chain.

Last edited by capink; 12-29-2021 at 04:18 AM.
capink is online now   Reply With Quote
Advert
Old 12-29-2021, 11:24 AM   #771
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
how would the variations work for this case? From what I understand, it changes the menu entry depending on...things, but whether I want to add a book to the TBR list is something I decide myself.
ownedbycats is offline   Reply With Quote
Old 12-29-2021, 12:30 PM   #772
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,091
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
how would the variations work for this case? From what I understand, it changes the menu entry depending on...things, but whether I want to add a book to the TBR list is something I decide myself.
By using the variant argument in a condition.

It should be as follows:
  • Make sure you have the experimental mode on by adding the following tweak (requires restarting):
    Code:
    action_chains_experimental = True
  • Use the chain variation template dialog to add your two variants as follows:
    Code:
    program:
        add_chain_variant('Send to Device','add_no');
        add_chain_variant('Send to Device + Add to TBR.','add_yes');
    The argument highlighted in blue will be passed to the chain and can be accessed later for enabling/disabling an action.
  • Add the following condition to the 'add to reading list' action:
    Code:
    Template : program: globals(_variant_argument)
    Comparison : =
    Value : add_yes

Now you should have two variants. Only one of them will pass the argument that satisfies the condition for running the 'add to reading list' action.

Last edited by capink; 12-29-2021 at 04:55 PM.
capink is online now   Reply With Quote
Old 12-29-2021, 01:31 PM   #773
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I see how that works now.

For the submenu/icon arguments, should I just use an empty string if I don't want it submenued?

EDIT: Empty string works.
Attached Files
File Type: zip SendToDeviceWithVariations.zip (6.8 KB, 67 views)

Last edited by ownedbycats; 12-29-2021 at 06:22 PM.
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 01:25 PM   #774
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Possible bug?

After restarting Calibre, the chains with variations temporarily disappear from the AC menu. They reappear after I open the config and save again. If it matters, it doesn't seem to delete keyboard shortcuts in use by them like when renaming a chain.

I restart in debug mode and I notice this error in the log:

Code:
Action Chains: Unable to create variant for chain (Send to Device)
Traceback (most recent call last):
  File "calibre_plugins.action_chains.action", line 345, in create_all_menu_actions_for_chain
  File "calibre_plugins.action_chains.action", line 355, in create_variants_menu_actions
  File "calibre_plugins.action_chains.action", line 394, in variants_from_config
AttributeError: 'ChainInterfaceAction' object has no attribute 'template_functions'

Last edited by ownedbycats; 12-31-2021 at 01:33 PM.
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 06:16 PM   #775
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,091
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
I added a new version to the first post. Try it and see if it helps with the error above.
capink is online now   Reply With Quote
Old 12-31-2021, 07:41 PM   #776
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That fixed it. thank you!
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 11:41 PM   #777
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
New glitch noticed after updating to newest version:

On my 'view' chain, view_manager_last_view() != 'Physical Books' in conditions results in an action consistently failing. Removing it made it work again. I got this error in the evaluator:

Code:
EXCEPTION:  Interpreter: Internal error evaluating an expression: 'eval_() missing 1 required positional argument: 'locals'' - line number 2
Here's the function:

Code:
from calibre_plugins.action_chains.templates import TemplateFunction

class ViewManagerLastVIew(TemplateFunction):

    name = 'view_manager_last_view'
    arg_count = 0

    def evaluate(self, formatter, kwargs, mi, locals):
        import calibre_plugins.view_manager.config as cfg
        gui = self.plugin_action.gui
        library_config = cfg.get_library_config(gui.current_db)
        return library_config.get(cfg.KEY_LAST_VIEW, '')

Thankfully, current_virtual_library_name() works just as well (maybe better) for my purposes - but was something used in it deprecated or changed?

Last edited by ownedbycats; 12-31-2021 at 11:44 PM.
ownedbycats is offline   Reply With Quote
Old 01-01-2022, 11:45 AM   #778
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,091
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Version 1.15.0 - 1 January 2022
  • Update: New action: Save/Restore Format.
  • Fix: Update templates before running template evaluator.
  • Fix: Error at startup building chain variations.

Version 1.15.1 - 1 January 2022
  • Fix: Regression with user defined templates.
capink is online now   Reply With Quote
Old 01-03-2022, 03:37 AM   #779
MikePatch
Member
MikePatch began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Dec 2021
Device: Kobo Libra 2
This plugin is a masterpiece!

Is it possible to use in action the bulk function to "Swap title and author"?
(I didn't find a way!)

Thx
Mike
MikePatch is offline   Reply With Quote
Old 01-03-2022, 07:29 AM   #780
compurandom
Guru
compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.
 
Posts: 919
Karma: 417282
Join Date: Jun 2015
Device: kobo aura h2o, kobo forma
I'm looking for a more selective selection.
Something like given this search and sort, select variations of:
  • The first 10 items
  • The 10 items after an offset
  • a random 10 items
  • everything except the first 10 items
compurandom is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Editor Plugin] Editor Chains capink Plugins 85 Today 05:50 AM
Action Chains Resources capink Plugins 54 01-29-2024 11:24 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


All times are GMT -4. The time now is 05:32 PM.


MobileRead.com is a privately owned, operated and funded community.