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-12-2021, 05:20 PM   #31
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Also while making that template I noticed if I accidentally put $$fanficcat (which is a column that does not exist), the first clause returned for every book. Is this intended?
ownedbycats is offline   Reply With Quote
Old 04-12-2021, 05:46 PM   #32
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Do you mean the slashes in this statement?
Code:
list_re($tags, ',', '\.', '\')
For me, those are backslashes. The character '/' is a forward slash.

Unfortunately the regexp-based template language lexical analyser cannot handle escaped backslashes. To do what you want you must use some other character.

Quote:
Also, how would you apply a sublist of just first item to the list_re? See the third item in the screenshot. I tried enclosing it but I broke it. This is for my #kobopath composite for a save template.
Do I understand you correctly, that you want to apply a regexp to the first item in a list? If so then do something like (not tested)
Code:
re(sublist($tags, 0, 1, ','), '^(.*?)($|\..*$)', '\1')

Last edited by chaley; 04-12-2021 at 06:03 PM. Reason: Correct the argument order for sublist
chaley is offline   Reply With Quote
Advert
Old 04-12-2021, 05:46 PM   #33
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Also while making that template I noticed if I accidentally put $$fanficcat (which is a column that does not exist), the first clause returned for every book. Is this intended?
Yes. $$ means raw_field. A non-existent field returns 'None'.
chaley is offline   Reply With Quote
Old 04-12-2021, 05:59 PM   #34
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I found a post saying that both slashes could be used and it'll be normalized, so I switched it:

Code:
program:

if $$#fanficcat then
		re(sublist($tags, ',', 0, 1), '\.', '/')

elif $formats == 'PDF' then
   'PDF'

else
		re(sublist($tags, ',', 0, 1), '^(.*?)($|\..*$)', '\1')
fi
Unfortunately now I am getting an invalid literal for int() with base 10: ',' What happened?
ownedbycats is offline   Reply With Quote
Old 04-12-2021, 06:02 PM   #35
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I found a post saying that both slashes could be used and it'll be normalized, so I switched it:

Code:
program:

if $$#fanficcat then
		re(sublist($tags, ',', 0, 1), '\.', '/')

elif $formats == 'PDF' then
   'PDF'

else
		re(sublist($tags, ',', 0, 1), '^(.*?)($|\..*$)', '\1')
fi
Unfortunately now I am getting an invalid literal for int() with base 10: ',' What happened?
Because I (and you) didn't get the arguments to sublist right. They are
Code:
sublist(list_string, start_index, end_index, separator)
We both put the separator as the second argument instead of the 4th.
chaley is offline   Reply With Quote
Advert
Old 04-12-2021, 06:06 PM   #36
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:

# Returns 'Fanfiction/Fandom' for fanfics
	if $$#fanficcat then
		re(sublist($tags, 0, 1, ','), '\.', '/')

# Returns 'PDF' for PDFs
	elif $formats == 'PDF' then
		'PDF'

# Returns topmost tag for all other books
	else
		re(sublist($tags, 0, 1, ','), '^(.*?)($|\..*$)', '\1')

	fi
this works!

Last edited by ownedbycats; 04-12-2021 at 06:08 PM.
ownedbycats is offline   Reply With Quote
Old 04-13-2021, 02:35 PM   #37
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: If you have two if statements that are mutually exclusive:

Code:
program:
	if $#enum== 'foo' then
		'foo'

	else $#enum == 'bar' then
		'bar'

	fi
does it matter what order they are in, as long as the other statements are all in the right order?

Last edited by ownedbycats; 04-13-2021 at 02:38 PM.
ownedbycats is offline   Reply With Quote
Old 04-13-2021, 02:53 PM   #38
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: If you have two if statements that are mutually exclusive:

Code:
program:
	if $#enum== 'foo' then
		'foo'

	else $#enum == 'bar' then
		'bar'

	fi
does it matter what order they are in, as long as the other statements are all in the right order?
Functionally, no, as long as you can truly guarantee mutual exclusivity. However, there might be differences in performance. The most common ones should be first.
chaley is offline   Reply With Quote
Old 04-13-2021, 07:41 PM   #39
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
In regards to this:

Quote:
Nope, the data that is copied is the data you see, formatted as you
specify in the tweaks. Doing anything else would be magic, a DWIMNWIS
(Do What I Mean Not What I Say) moment.

If you want to copy exact timestamps then you need to use the "template"
source and raw_field() to get the full timestamp, then store that
timestamp where you wish. (Yes, it can be more complicated than this.)
Outside of Action Chain's single-field edit, where do I do this?
ownedbycats is offline   Reply With Quote
Old 04-13-2021, 07:49 PM   #40
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
In regards to this:
Quote:
Nope, the data that is copied is the data you see,
Outside of Action Chain's single-field edit, where do I do this?
Your bug report was about multiple book search and replace. That dialog in regexp mode supports "Template" as the source field.
chaley is offline   Reply With Quote
Old 04-13-2021, 08:02 PM   #41
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I see it now.
ownedbycats is offline   Reply With Quote
Old 04-14-2021, 05:06 PM   #42
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Can a gpm statement be used for a save template?

I currently have a #kobopath gpm composite which then passes itself into my save templates; I thought I could skip that intermediary step.

Last edited by ownedbycats; 04-14-2021 at 05:14 PM.
ownedbycats is offline   Reply With Quote
Old 04-14-2021, 06:56 PM   #43
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,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Can a gpm statement be used for a save template?

I currently have a #kobopath gpm composite which then passes itself into my save templates; I thought I could skip that intermediary step.
No. Save templates are basic python templates, not calibre ones. You can't do anything that isn't described here.

Why? These templates predate the template language by several years.
chaley is offline   Reply With Quote
Old 04-14-2021, 06:59 PM   #44
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Ok. That's good to know that before I started trying to kludge something together.
ownedbycats is offline   Reply With Quote
Old 04-16-2021, 02:07 AM   #45
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: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
This (it's still a WIP; I am still debating whether this will be better than multiple non-template rules) returns a syntax error about an unexpected end of program near "unknown." Where exactly is the mistake?

Code:
program:
	vl = $#vls;
	pc = $$#pagecount;
	fmt = $$#formats;
	lang = $$#languages

	if
		'Cleanup' in vl
	then
		
# Checks for a missing format
		if
			fmt == ''
		then
			'add_book.png'
		fi
			
# Checks for a missing pagecount
		if
			pc == 'None'
		then
			'cover_flow.png'
		fi
		
# Checks for a missing language
		if
			lang == 'None'
		then
			'languages.png'
		fi
		
# Checks for an ORIGINAL_EPUB in formats
		if
			fmt == 'ORIGINAL_EPUB'
		then
			'add_book.png'
		fi

# Returns a generic icon if no specific issue is flagged
	else 
		'polish.png'
	fi

Last edited by ownedbycats; 04-16-2021 at 02:18 AM.
ownedbycats 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 178 11-12-2024 03:14 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 03:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 12:37 PM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 10:19 PM
Thread management questions meme Feedback 6 01-31-2011 06:07 PM


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


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