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 05-13-2022, 05:17 AM   #856
MikePatch
Member
MikePatch began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Dec 2021
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
Hey, a make a module.
The purpose of this module is to update the title and/or author sorting key, like the options in the Bulk Metadata dialog, options that are unavailable via Action Chains (I won't open the huge Bulk Metadata dialog just to check the same 2 options everytime => go on to make a non-interactive module).

I remember you had created a thread to reference different user modules (and other event managers), but I couldn't find it.
If it exists, it would be nice to have an explicit link in the description (so that we can look for it before breaking our heads to do things ourselves, especially if we don't understand anything in code)

Here is the code of the module:
EDIT: code moved into the dedicated thread
I'm getting this message adding you code
"calibre, version 5.42.0
ERROR: Invalid Python code: The code you created is not valid Python code, with error: 'NoneType' object has no attribute 'split'"

Could you please help me?

MP
MikePatch is offline   Reply With Quote
Old 05-13-2022, 10:17 AM   #857
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by MikePatch View Post
I'm getting this message adding you code
"calibre, version 5.42.0
ERROR: Invalid Python code: The code you created is not valid Python code, with error: 'NoneType' object has no attribute 'split'"

Could you please help me?

MP
Thats was weird. I'm also on 5.42.0 so...
What language do you use?

I update the code modules with a smal fix, but I am really, really intrigued to know more about how this bug happened.
un_pogaz is offline   Reply With Quote
Advert
Old 05-13-2022, 11:38 AM   #858
MikePatch
Member
MikePatch began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Dec 2021
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
Thats was weird. I'm also on 5.42.0 so...
What language do you use?

I update the code modules with a smal fix, but I am really, really intrigued to know more about how this bug happened.
I use English language
another info it is a portable calibre.
MikePatch is offline   Reply With Quote
Old 05-13-2022, 01:58 PM   #859
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by MikePatch View Post
I use English language
another info it is a portable calibre.
Okay. No idea how this could happen.
Oh well, the fix work?
un_pogaz is offline   Reply With Quote
Old 05-13-2022, 03:25 PM   #860
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,090
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by un_pogaz View Post
Okay. No idea how this could happen.
Oh well, the fix work?
I can confirm the bug happens to me as well. Also can confirm that your fix solves the problem.

The reason for the bug is that set_translators.lang returns None for people who have English language as their interface language. Both yourself and Terisa de Morgan have languages other than English (languages that need translators), so the bug cannot be caught on your systems.

You can test this yourself by temporarily switching to English.
capink is offline   Reply With Quote
Advert
Old 05-13-2022, 04:48 PM   #861
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by capink View Post
I can confirm the bug happens to me as well. Also can confirm that your fix solves the problem.

The reason for the bug is that set_translators.lang returns None for people who have English language as their interface language. Both yourself and Terisa de Morgan have languages other than English (languages that need translators), so the bug cannot be caught on your systems.

You can test this yourself by temporarily switching to English.
Usually it's in the other way (problem if you have a translated interface)
Terisa de morgan is offline   Reply With Quote
Old 05-14-2022, 05:01 PM   #862
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 410
Karma: 145324
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by capink View Post
I can confirm the bug happens to me as well. Also can confirm that your fix solves the problem.

The reason for the bug is that set_translators.lang returns None for people who have English language as their interface language. Both yourself and Terisa de Morgan have languages other than English (languages that need translators), so the bug cannot be caught on your systems.

You can test this yourself by temporarily switching to English.
Oh, Aah.
I found it strange because sometimes I test my plugin/module in others languages but I had never seen that because when I switch to English, I use "English (United Kingdom)" which returns en_GB, but there is another "English" (the true default) which gives None.
I take note of this subtility.

Also, edit my code to not raise a execption with this case. try catch a exception is a emergency solution, not the default or valide way.

Last edited by un_pogaz; 05-14-2022 at 05:09 PM.
un_pogaz is offline   Reply With Quote
Old 05-15-2022, 01:32 PM   #863
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Hi, I've been using action chains for a while now and I have a question, I've been searching online all day, been looking at the template functions, but I can't figure out how they work without an example that make sense.
I just can't find the answer to this question.

We all know AO3 is a mess when it comes to tags. So I've created a separate column for them (#ao3tags). Some of them I actually want to use within my column (#genre) others I just want to leave as be.

How to I move a number of specific tags from one column to the other with leaving the rest untouched?

For example you have the tags
Code:
car, tram, train, bike, bus, boat, ferry, cat, dog,
and then I want
Code:
^tram$|^train$|^bus$|^ferry$
to be moved from the column
Code:
#ao3tags
to the column
Code:
#genre
While leaving the rest in the tags column.

Obviously you won't see these tags in a fanfic, but it illustrates the purpose.

I've tried using the search and replace, but the problem is that it not only amends and moves the tags I want, but also the ones I don't want in my 2nd column.

Can this be done using template functions, and if so can you code different replacements within the same template?
ackomb is offline   Reply With Quote
Old 05-15-2022, 01:46 PM   #864
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Off the top of my head, you can do this in search & replace.

Search field: template
Search template: program: list_intersection($#ao3tags, 'tram, train, bus, ferry', ',')
Search for: (^.*$)
Replace with: \1
Destination field: #genre
Mode: Append to field

The template produces a list of acceptable values (the second parameter) from tags. The rest S&R appends that list to #genre. Duplicates will be removed in that process.

EDIT: You didn't say if you want to use Action Chains Single Field Edit. If you do then this template should work
Code:
program:
	a = list_intersection($ao3tags, 'tram, train, bus, ferry', ',');
	list_union($#genre, a, ',')

Last edited by chaley; 05-15-2022 at 02:03 PM. Reason: Corrected the tag name, added template suitable for single field edit
chaley is offline   Reply With Quote
Old 05-15-2022, 03:21 PM   #865
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Quote:
Originally Posted by chaley View Post
Off the top of my head, you can do this in search & replace.

Search field: template
Search template: program: list_intersection($#ao3tags, 'tram, train, bus, ferry', ',')
Search for: (^.*$)
Replace with: \1
Destination field: #genre
Mode: Append to field

The template produces a list of acceptable values (the second parameter) from tags. The rest S&R appends that list to #genre. Duplicates will be removed in that process.

EDIT: You didn't say if you want to use Action Chains Single Field Edit. If you do then this template should work
Code:
program:
	a = list_intersection($ao3tags, 'tram, train, bus, ferry', ',');
	list_union($#genre, a, ',')
Thanks, that got me going in the right direction. I'm going to fiddle with it for a while.

ackomb is offline   Reply With Quote
Old 05-16-2022, 04:14 PM   #866
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
So I have a question why is it not possible to amend listed items in items editor, under predefined values?
Every time, I want to change it/add a value, I get asked to discard the values and I have to start all over again.

Is there a way to change this, so you can amend the list rather then discard it?
Attached Thumbnails
Click image for larger version

Name:	Schermafbeelding 2022-05-16 220714.jpg
Views:	73
Size:	20.2 KB
ID:	193852  
ackomb is offline   Reply With Quote
Old 06-25-2022, 09:03 AM   #867
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Remove all tags but leave X, Y, Z

So I find action chains very useful, but right now I'm stuck on something. I've use the chains to amend certain tags to something a bit more generic. So for example, I've changed all categories from Supergirl, Supercorp, Danvers into Arrowverse, and Clexa, 100, Ranya into the 100 etc. etc. But there are still tags that are useless such as 'more tags will be added', 'other' or tags that actually belong to the characters rather then category, which I've also tackled with the action chains. But in the end I want Action Chains to remove all tags from category but leave 'the 100' and 'Arrowverse'

I've found a way to remove 'all' tags or remove 'certain' tags but not 'all but' X, Y, Z.

Could use your help on this one.
ackomb is offline   Reply With Quote
Old 06-25-2022, 09:24 AM   #868
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
So I find action chains very useful, but right now I'm stuck on something. I've use the chains to amend certain tags to something a bit more generic. So for example, I've changed all categories from Supergirl, Supercorp, Danvers into Arrowverse, and Clexa, 100, Ranya into the 100 etc. etc. But there are still tags that are useless such as 'more tags will be added', 'other' or tags that actually belong to the characters rather then category, which I've also tackled with the action chains. But in the end I want Action Chains to remove all tags from category but leave 'the 100' and 'Arrowverse'

I've found a way to remove 'all' tags or remove 'certain' tags but not 'all but' X, Y, Z.

Could use your help on this one.
My guess is you want to use list_intersection() similarly to what I described in post 864, as in
Code:
program:
	list_intersection($tags, 'X, Y, Z', ',')
The function returns items in $tags that are also in the list 'X, Y, Z', e.g. if the tags are 'A, B, X, Z' then the function returns 'X, Z'.
chaley is offline   Reply With Quote
Old 06-25-2022, 10:09 AM   #869
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Quote:
Originally Posted by chaley View Post
My guess is you want to use list_intersection() similarly to what I described in post 864, as in
Code:
program:
	list_intersection($tags, 'X, Y, Z', ',')
The function returns items in $tags that are also in the list 'X, Y, Z', e.g. if the tags are 'A, B, X, Z' then the function returns 'X, Z'.
I do actually, never thought about using it this way as well, but I guess that would work if instead of append to field I use replace field??

Works perfect except for one little snag, where I had to circumvent an ' in one of the tags with a \ like in regex.

Last edited by ackomb; 06-25-2022 at 10:54 AM.
ackomb is offline   Reply With Quote
Old 06-25-2022, 04:57 PM   #870
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
Works perfect except for one little snag, where I had to circumvent an ' in one of the tags with a \ like in regex.
Another way to handle that is to use " as a string delimiter instead of '. Example: "a, b'c, d" is valid without the escapes. If the string contains both " and ' characters then you must escape one of them.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Editor Plugin] Editor Chains capink Plugins 82 04-02-2024 10:56 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 07:35 AM.


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