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 03-24-2023, 06:02 PM   #1051
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Unexpected behaviour:

1. Create a chain with single-field edit that modifies an HTML longtext column. (I use it to add series descriptions to the aptly-named #seriesdescription.)
2. Run it on multiple books.
3. Without editing anything, switch to 'HTML source' tab and then back to 'Normal view'

The 'Apply to all' button will then enable itself as though the user had edited something.

Last edited by ownedbycats; 03-24-2023 at 06:21 PM.
ownedbycats is online now   Reply With Quote
Old 03-25-2023, 02:07 PM   #1052
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,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
This is harmless. It comes from the original Comment Editor in calibre, which is not designed with bulk editing in mind. And I don't feel like rewriting it and maintaining a separate version just for this.
capink is offline   Reply With Quote
Old 03-26-2023, 12:06 PM   #1053
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quick question on interaction between AC and Last Modified:

If a single-field edit with a predefined value doesn't change the value, will it trigger a last modified datechange on that column?

Example: I have a book with #booktype set to Fiction. I run a chain where the only action is to set #booktype to Fiction.

I'm also curious how this works with templates. In pretty much all cases I have a "else $columnname" to return the currently-existing value rather than nulling it out. Would this count as a modificaiton or not?
ownedbycats is online now   Reply With Quote
Old 03-26-2023, 01:26 PM   #1054
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,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
Quick question on interaction between AC and Last Modified:

If a single-field edit with a predefined value doesn't change the value, will it trigger a last modified datechange on that column?

Example: I have a book with #booktype set to Fiction. I run a chain where the only action is to set #booktype to Fiction.

I'm also curious how this works with templates. In pretty much all cases I have a "else $columnname" to return the currently-existing value rather than nulling it out. Would this count as a modificaiton or not?
If you want to preserve the last modified column(s), stick to templates, because unlike pre-defined option it will check with the old value before updating. Returning "else $columnname" will not count as modification.
capink is offline   Reply With Quote
Old 03-26-2023, 02:01 PM   #1055
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
If you want to preserve the last modified column(s), stick to templates, because unlike pre-defined option it will check with the old value before updating. Returning "else $columnname" will not count as modification.
Also, in most cases the calibre db layer checks if the item is being set to itself and doesn't change last_modified.

You could of course test this easily enough...
chaley is offline   Reply With Quote
Old 03-26-2023, 02:05 PM   #1056
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,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
Also, in most cases the calibre db layer checks if the item is being set to itself and doesn't change last_modified.

You could of course test this easily enough...
Yes I forgot about that when I replied. @chaley introduced a change to calibre db to solve a problem with the LM plugin. So, you can use whatever option without worrying about updating with the same value.

The checking of values with the template option precedes chaley's change to the db. I will look into removing this step to improve performance.
capink is offline   Reply With Quote
Old 03-26-2023, 02:55 PM   #1057
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks
ownedbycats is online now   Reply With Quote
Old 04-01-2023, 08:54 PM   #1058
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is there a method that runs a regex on a column and then copies the substituted value to clipboard? I'd like to extract a string from FanFicFare-populated #fanficmetadata column.

EDIT: Copy to clipboard, template using re.

Last edited by ownedbycats; 04-02-2023 at 12:59 AM.
ownedbycats is online now   Reply With Quote
Old 04-02-2023, 01:10 AM   #1059
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
New question:

Can Action Chains be used to insert links into the author table? (Or, post 6.14.1+, other normalized tables as well.)

In my specific case I'd like to:
1. Use template to extract a string from #fanficmetadata.
2. Insert it into the author (or series) table.

Multiple authors may be a problem -- I would probably just do those ones manually.

Last edited by ownedbycats; 04-02-2023 at 01:12 AM.
ownedbycats is online now   Reply With Quote
Old 04-02-2023, 06:02 AM   #1060
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here are two python stored templates you can use for this.

This one returns the link associated with a value in a column.
Code:
python:
def evaluate(book, context):
	arguments = context.arguments
	if arguments is None or len(arguments) != 2:
		raise ValueError('template needs 2 arguments: column, value')
	db = context.db.new_api
	links = db.get_link_map(arguments[0])
	return links.get(arguments[1], '')
Example call:
Code:
program: get_links_for_value('series', '1632')
It returns the empty string if no link exists.

This template sets a link for a value in a column:
Code:
python:
def evaluate(book, context):
	arguments = context.arguments
	if arguments is None or len(arguments) != 3:
		raise ValueError('template needs 3 arguments: column, value, link')
	to_set_map = {arguments[1]:arguments[2]}
	db = context.db.new_api
	db.set_link_map(arguments[0], to_set_map)	
	return arguments[2]
It returns the link text if successful.

Example call:
Code:
program: set_link_for_value('series', 'Bah', 'some link')
chaley is offline   Reply With Quote
Old 04-04-2023, 05:30 PM   #1061
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I'd like to make a single-field edit that changes series_index to '0' if a template returns true. However, series_index is not available for selection in the dropdown menu.

Are there other options or a workaround using the 'series' column?

EDIT: Search & replace may work.

ANOTHER EDIT: What's going on with the width of the dialog? lol
Attached Thumbnails
Click image for larger version

Name:	2023-04-04 20_07_00-Editing metadata for one book.png
Views:	786
Size:	43.6 KB
ID:	200787   Click image for larger version

Name:	2023-04-04 20_07_28-Search And Replace.png
Views:	835
Size:	28.7 KB
ID:	200788   Click image for larger version

Name:	2023-04-04 20_32_24-Search And Replace.png
Views:	821
Size:	32.6 KB
ID:	200789  

Last edited by ownedbycats; 04-04-2023 at 11:02 PM.
ownedbycats is online now   Reply With Quote
Old 04-05-2023, 02:43 PM   #1062
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I'm having a bit of trouble figuring out how formulas work and am wondering if I'm misusing it here.

Code:
program: 
## Field guides, fanfiction exchanges, and various other unordered series
collections = first_non_empty(
	'Golden Guides' in $series,
	'Mass Effect Big Bang \d{4}' in $series,
	'Spectre Requisitions \d{4}' in $series,
	'N7 Exchange \d{4}' in $series,
	'Across Dark Space \d{4}' in $series,
	);

	if collections then columnupdate_seriesindex(0) fi
This is the code of columnupdate_seriesindex(). It changes the seriesindex to the argument.

This works as expected if I run it on a single book - if the series matches 'collections' it changes series_index to 0. It also works if I run it on two books that match or two books that don't match.

If I run it on two books where one matches and the other doesn't, it just results in an empty window (and the matched book fails to update). I'm thinking it's checking both books at once instead of each one separately.
ownedbycats is online now   Reply With Quote
Old 04-05-2023, 02:53 PM   #1063
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'm having a bit of trouble figuring out how formulas work and am wondering if I'm misusing it here.

Code:
program: 
## Field guides, fanfiction exchanges, and various other unordered series
collections = first_non_empty(
	'Golden Guides' in $series,
	'Mass Effect Big Bang \d{4}' in $series,
	'Spectre Requisitions \d{4}' in $series,
	'N7 Exchange \d{4}' in $series,
	'Across Dark Space \d{4}' in $series,
	);

	if collections then columnupdate_seriesindex(0) fi
This is the code of columnupdate_seriesindex(). It changes the seriesindex to the argument.

This works as expected if I run it on a single book - if the series matches 'collections' it changes series_index to 0. It also works if I run it on two books that match or two books that don't match.

If I run it on two books where one matches and the other doesn't, it just results in an empty window (and the matched book fails to update). I'm thinking it's checking both books at once instead of each one separately.
The python template runs on a selection. After thought, I suggest that your action chain uses a selection modifier (a template search using code similar to above) to change the selection to the books you want, then uses a formula action to update all selected books.

Or a Search using Templates followed by a Selection Modifer to select all books in the current library view.
chaley is offline   Reply With Quote
Old 04-05-2023, 02:56 PM   #1064
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That makes sense I'll try it. Thanks.
ownedbycats is online now   Reply With Quote
Old 04-07-2023, 03:22 PM   #1065
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: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by capink View Post
Here is a modified version of the Chain Caller action (called Modified Chain Caller) that can call a target chain multiple times to process chunks of books for each iteration.

Code:
#!/usr/bin/env python
# ~*~ coding: utf-8 ~*~

from qt.core import (QApplication, Qt, QWidget, QGridLayout, QHBoxLayout, QVBoxLayout,
                      QGroupBox, QComboBox, QCheckBox, QSpinBox)

from calibre import prints
from calibre.constants import DEBUG

from calibre_plugins.action_chains.chains import Chain
import calibre_plugins.action_chains.config as cfg


from calibre_plugins.action_chains.actions.chain_caller import ChainCallerAction


tooltip = '''
This option splits the books into multiple chunks and run the target chain multiple times,
each time processing a chunk of books. The chunk size can be selected in the spin box.
The book ids in each chunk is passed to the target chain in a variabe called _book_ids.
You must adjust the scope of the actions in the target chains using a template scope to
act on this variable.
'''

class ConfigWidget(QWidget):
    def __init__(self, plugin_action, chain_name, chains_config, *args, **kwargs):
        QWidget.__init__(self)
        self.plugin_action = plugin_action
        self.gui = plugin_action.gui
        self.db = self.gui.current_db
        self.chain_name = chain_name
        self.chains_config = chains_config
        self._init_controls()

    def _init_controls(self):

        l = self.l = QVBoxLayout()
        self.setLayout(l)

        chain_groupbox = QGroupBox(_('Select chain'))
        l.addWidget(chain_groupbox)
        chain_groupbox_l = QVBoxLayout()
        chain_groupbox.setLayout(chain_groupbox_l)
        self.chain_combo = QComboBox()
        chain_groupbox_l.addWidget(self.chain_combo)

        opts_groupbox = QGroupBox(_('Options'))
        opts_groupbox_l = QVBoxLayout()
        opts_groupbox.setLayout(opts_groupbox_l)
        l.addWidget(opts_groupbox)

        vars_chk = self.vars_chk = QCheckBox(_('Pass variables from calling chain'))
        vars_chk.setChecked(False)
        opts_groupbox_l.addWidget(vars_chk)

        #all_chain_names = [chain_config['menuText'] for chain_config in cfg.get_chains_config()]
        all_chain_names = [chain_config['menuText'] for chain_config in self.chains_config if chain_config['menuText']]
        try:
            all_chain_names.remove(self.chain_name)
        except:
            pass
        self.chain_combo.addItems(all_chain_names)
        self.chain_combo.setCurrentIndex(-1)

        spin_group_box = self.spin_group_box = QGroupBox('Split books into chunks')
        spin_group_box.setCheckable(True)
        spin_group_box.setChecked(False)
        spin_group_box_l = QVBoxLayout()
        spin_group_box.setLayout(spin_group_box_l)
        l.addWidget(spin_group_box)
        spin_group_box.setToolTip(tooltip)
        self.spinbox = QSpinBox()
        self.spinbox.setMaximum(100000)
        self.spinbox.setMinimum(1)
        self.spinbox.setSingleStep(1)
        self.spinbox.setValue(10)
        spin_group_box_l.addWidget(self.spinbox)

        l.addStretch(1)

        self.setMinimumSize(300,300)

    def load_settings(self, settings):
        if settings:
            idx = self.chain_combo.findText(settings['chain_name'])
            self.chain_combo.setCurrentIndex(idx)
            self.vars_chk.setChecked(settings.get('pass_vars', False))
            self.spin_group_box.setChecked(settings.get('split_to_chunks', False))
            self.spinbox.setValue(settings.get('chunk_size', 10))

    def save_settings(self):
        settings = {}
        settings['chain_name'] = self.chain_combo.currentText()
        settings['pass_vars'] = self.vars_chk.isChecked()
        settings['split_to_chunks'] = self.spin_group_box.isChecked()
        settings['chunk_size'] = self.spinbox.value()
        return settings

class ModifiedChainCallerAction(ChainCallerAction):

    name = 'Modified Chain Caller'
    is_experimental = False

    def run(self, gui, settings, chain):
        # Chain variables {
        add_to_vars = {}
        if settings.get('pass_vars'):
            add_to_vars = self.sanitize_chain_vars(chain)
        add_to_vars['_caller'] = chain.chain_name
        # }
        book_ids = chain.scope().get_book_ids()
        if settings.get('split_to_chunks', False):
            chunk_size = settings['chunk_size']
            chunks = [book_ids[x:x+chunk_size] for x in range(0, len(book_ids), chunk_size)]
        else:
            chunks = [book_ids]
        chunks_no = len(chunks)
        for i, chunk in enumerate(chunks):
            prints('Action Chains: Chain Caller: running chunk no {} of {}'.format(i, chunks_no))
            add_to_vars['_book_ids'] = ','.join([str(x) for x in chunk])
            target_chain_config = cfg.get_chain_config(settings['chain_name'])
            target_chain = Chain(self.plugin_action, target_chain_config, show_progress=False,
                                add_to_vars=add_to_vars, chain_caller=True)
            target_chain.run()
            del target_chain

    def config_widget(self):
        return ConfigWidget
You should use this Modified Chain Caller to call your target chain as follows:
  1. Add the Modified Chain Caller as a custom action using the module editor (Action Chains > manage modules > create module > copy/paste the code above)
  2. Create a new chain that consists of a single action > Modified Chain Caller.
  3. In the settings of the Modified Chain Caller, choose your target chain from the dropdown menu.
  4. In the settings of the Modified Chain Caller, tick the box for splitting books into chunks, and choose the chunk size (default is 10 books)
  5. In your target chain, all the actions must have a template scope with the following template:
    Code:
    program:
        globals(_book_ids)
  6. Now select the books you want to process, and run the Modified Chain Caller chain.

I am not sure whether this can help you with the out of memory problem, give it a try and see.
Question: If I set this to run on 1 book, can it get around problems when it's running on a selection rather than individual books?

Use-case 1: Running a single-field MDE with ask-at-runtime.
Use-case 2: Using an action with a conditional that checks something from the current book.
Use-case 3: This.

EDIT: Use-case 1 didn't work. I ran it on two books. Book selection didn't change (thought it would) and I got the information I entered for the second book on both.

I wonder now if this is something I can fudge with selection modifiers.

Last edited by ownedbycats; 04-07-2023 at 04:26 PM. Reason: spellcheck is misbehaving
ownedbycats is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 09:38 AM.


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