Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-24-2023, 04:40 AM   #601
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Somewhat related: What happens if a new template function shares the name as an already existing saved template?
Don't know for sure. I think that the existing function will be replaced with a body that returns an error. I am doing other things so I am not going to test this.
chaley is offline   Reply With Quote
Old 04-24-2023, 04:44 AM   #602
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,851
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
This probably won't be a problem unless you plan to name one of the functions has_data(). And I'll probably see it in the changelogs first
ownedbycats is online now   Reply With Quote
Advert
Old 04-24-2023, 04:51 AM   #603
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
This probably won't be a problem unless you plan to name one of the functions has_data(). And I'll probably see it in the changelogs first
The equivalent function will be named has_extra_data(). I am also planning to add functions extra_data_files(sep) that returns a sep-separated list of files, extra_data_file_modtime(file_name), and extra_data_file_size(file_name).
chaley is offline   Reply With Quote
Old 04-30-2023, 03:21 PM   #604
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
I found something similar in this post ( https://www.mobileread.com/forums/sh...&postcount=537 ) to what I'm looking to do in my library but can't get it to work for me.
Let me explain I have personal identifiers in the ids field
and a personalized column of which store I bought the book.
What I'm looking for is that if the store custom column says Amazon, it only brings me the Amazon ids in another column.
It seems to me that it is the essence of that form but it brings me all the identifiers
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	68
Size:	186.1 KB
ID:	201356  

Last edited by dunhill; 04-30-2023 at 03:27 PM.
dunhill is offline   Reply With Quote
Old 04-30-2023, 03:36 PM   #605
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
I found something similar in this post ( https://www.mobileread.com/forums/sh...&postcount=537 ) to what I'm looking to do in my library but can't get it to work for me.
Let me explain I have personal identifiers in the ids field
and a personalized column of which store I bought the book.
What I'm looking for is that if the store custom column says Amazon, it only brings me the Amazon ids in another column.
It seems to me that it is the essence of that form but it brings me all the identifiers
Sorry but I don't know what you are asking. What doesn't work? What is the template? What are the values it is operating on?
chaley is offline   Reply With Quote
Advert
Old 04-30-2023, 04:57 PM   #606
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
Sorry but I don't know what you are asking. What doesn't work? What is the template? What are the values it is operating on?
I have modified the template to my options

program:

def do_one(ids, check_value, select_identifier):
if = select(ids, select_identifier);
if
!$#libreria==check_value && if
then
return list_difference(ids, strcat(select_identifier, if), ',')
fi;
return ids
fed;

ids = do_one($identifiers, "Amazon",'amazon');
ids = do_one(ids, "Cuspide", 'cuspide');
ids = do_one(ids, "Yenny", 'yenny');
ids = do_one(ids, "Baen", 'baen')


I have a column #libreria is the store where I buy the book
Usually Yenny
and in the identifiers cargo yenny:9789504968566

what I wanted is if in the store field it is Yenny just see the isbn of yenny

Last edited by dunhill; 04-30-2023 at 05:10 PM.
dunhill is offline   Reply With Quote
Old 04-30-2023, 05:23 PM   #607
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
I have modified the template to my options
program:

def do_one(ids, check_value, select_identifier):
if = select(ids, select_identifier);
if
!$#libreria==check_value && if
then
return list_difference(ids, strcat(select_identifier, if), ',')
fi;
return ids
fed;

ids = do_one($identifiers, "Amazon",'amazon');
ids = do_one(ids, "Cuspide", 'cuspide');
ids = do_one(ids, "Yenny", 'yenny');
ids = do_one(ids, "Baen", 'baen')

I have a column #libreria is the store where I buy the book
Usually Yenny
and in the identifiers cargo yenny:9789504968566

what I wanted is if in the store field it is Yenny just see the isbn of yenny
That template is incorrect. It uses a variable named 'if', which is a keyword. Here is a corrected version of the template. (Please use code tags for templates!)
Code:
program:
	def do_one(ids, check_value, select_identifier):
		sel = select(ids, select_identifier);
		if
			!$#libreria==check_value && sel
		then
			return list_difference(ids, strcat(select_identifier, sel), ',')
		fi;
		return ids
	fed;
	
	ids = do_one($identifiers, "Amazon",'amazon');
	ids = do_one(ids, "Cuspide", 'cuspide');
	ids = do_one(ids, "Yenny", 'yenny');
	ids = do_one(ids, "Baen", 'baen')
That said, I don't understand what this template is supposed to do. The function do_one() seems to do nothing if the check_value (the second parameter) equals the contents of #libreria. Said another way, it removes any identifier where the id name == the third parameter (select_identifier) and the store ($#libreria) does not equal to the second parameter (check_value). For example, the third call to do_one() does nothing if #libreria equals 'yenny', which from your text isn't what you want.

Sorry, but the complexity here is higher than I can cope with.
chaley is offline   Reply With Quote
Old 05-04-2023, 08:22 AM   #608
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,851
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
What is the best way to check a column for multiple patterns and return for any matches? Here is what I have:

Code:
program:

omnibus =
	if 
		'Box Set' in $title
		|| 'Complete Series' in $title
		|| '(Books|Volumes) (\d+-\d+)' in $title
	then
		'omnibus'
	else
		''
	fi;

list_union(omnibus, $#admintags, ',')
This is for use in an Action Chain. It adds 'omnibus' to #admintags if the title indicates it's one.

Last edited by ownedbycats; 05-04-2023 at 08:25 AM.
ownedbycats is online now   Reply With Quote
Old 05-04-2023, 08:29 AM   #609
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
What is the best way to check a column for multiple patterns and return for any matches? Here is what I have:

Code:
program:

omnibus =
	if 
		'Box Set' in $title
		|| 'Complete Series' in $title
		|| '(Books|Volumes) (\d+-\d+)' in $title
	then
		'omnibus'
	else
		''
	fi;

list_union(omnibus, $#admintags, ',')
This is for use in an Action Chain. It adds 'omnibus' to #admintags if the title indicates it's one.
Code:
program:

omnibus =
	if 
		'(Box Set)|(Complete Series)|((Books|Volumes) (\d+-\d+))' in $title
	then
		'omnibus'
	fi;
chaley is offline   Reply With Quote
Old 05-04-2023, 08:35 AM   #610
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,851
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Yes, I was thinking of doing something like that. Would make adding new patterns a bit tricky. I think that may not be an issue as the ones I have cover 80% of my existing omnibuses - I'm not going for every possible variation, just the most common ones.

Last edited by ownedbycats; 05-04-2023 at 08:39 AM. Reason: clarification
ownedbycats is online now   Reply With Quote
Old 05-04-2023, 08:38 AM   #611
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Yes, I was thinking of doing something like that. Would make adding new patterns a bit tricky. But I'm not going for every possible variation, just the most common ones.
Using regex alternation (or) is much faster than doing sequential checks. And there is nothing to prevent you from adding another check if fitting into alternation is too hard.
chaley is offline   Reply With Quote
Old 05-06-2023, 04:09 PM   #612
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,851
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Mostly out of curiosity about how something works again.

program: $#timesread + 1
This returns '1'

program: add($#timesread, 1)
This returns '1.0'

Why are they different?

(also just realized I should be using $$, oops...)

Last edited by ownedbycats; 05-06-2023 at 04:11 PM.
ownedbycats is online now   Reply With Quote
Old 05-06-2023, 04:27 PM   #613
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,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Mostly out of curiosity about how something works again.

program: $#timesread + 1
This returns '1'

program: add($#timesread, 1)
This returns '1.0'

Why are they different?

(also just realized I should be using $$, oops...)
Because the add() function was defined forever ago to always return a float. This can't change without potentially breaking templates.

The add operator (+) checks the result and converts the float to an int if the fractional part is zero. One can argue that defining it this way was wrong, but so be it.

Before you ask: no, I am not going to change the behavior of either one.

Note that the results are arithmetically identical.

If you don't like the ".0" then use round(), floor(), ceil(), fractional_part(), or format_number() to convert it. Or use re() to strip off the .0, as in
Code:
re(add(3), '^(.*)\.0$', '\1')
chaley is offline   Reply With Quote
Old 05-06-2023, 05:11 PM   #614
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,851
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
In this case, the output is being written to an int column so it'd turn out the same anyways.
ownedbycats is online now   Reply With Quote
Old 05-07-2023, 11:16 AM   #615
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
That template is incorrect. It uses a variable named 'if', which is a keyword. Here is a corrected version of the template. (Please use code tags for templates!)
Code:
program:
	def do_one(ids, check_value, select_identifier):
		sel = select(ids, select_identifier);
		if
			!$#libreria==check_value && sel
		then
			return list_difference(ids, strcat(select_identifier, sel), ',')
		fi;
		return ids
	fed;
	
	ids = do_one($identifiers, "Amazon",'amazon');
	ids = do_one(ids, "Cuspide", 'cuspide');
	ids = do_one(ids, "Yenny", 'yenny');
	ids = do_one(ids, "Baen", 'baen')
That said, I don't understand what this template is supposed to do. The function do_one() seems to do nothing if the check_value (the second parameter) equals the contents of #libreria. Said another way, it removes any identifier where the id name == the third parameter (select_identifier) and the store ($#libreria) does not equal to the second parameter (check_value). For example, the third call to do_one() does nothing if #libreria equals 'yenny', which from your text isn't what you want.

Sorry, but the complexity here is higher than I can cope with.

As I said before, I wanted to modify the ownbycats template

But I tell you what I have.
I have a custom identifier yenny and cuspide:

And a library column (which is where I bought the book from) Yenny, Cúspide, Amazon

I would like to have the identifier number in another column depending on the Library column.

If in the library column it says Yenny In another column it would have to show me only the identifier of yenny

If in the library column it says Cúspide In another column it would have to show me only the identifier of cuspide

If in the library column it says Amazon In another column it would have to show me only the amazon identifier

I thought that essentially what the ownbycats template did could help me, if you can guide me in this regard, I would be very grateful

Last edited by dunhill; 05-07-2023 at 11:19 AM.
dunhill is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 153 05-14-2024 01:30 AM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


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


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