![]() |
#646 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
In my specific case, I've started copying the previous last-read dates to #admintags, as 'read:2020-04-16'.
Here's the template I used to make the list: Code:
program: most_recent= format_date($$#lastread, 'yyyy-MM-dd'); old_dates= list_re($#admintags, ',', 'read:', ' '); date_list= list_sort(list_union(most_recent, old_dates, ','), 0, ',') Additionally: is using list_re to replace 'read:' with a space the proper method? ![]() |
![]() |
![]() |
![]() |
#647 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,427
Karma: 6083323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Code:
old_dates= re($#admintags, ',', 'read:', ' '); |
||
![]() |
![]() |
![]() |
#648 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Due to people posting non-template questions here, I made a new thread for small library management questions:
https://www.mobileread.com/forums/sh...d.php?t=355273 |
![]() |
![]() |
![]() |
#649 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Jul 2023
Device: Onyx Boox Poke 5, Nova 3
|
![]()
What would be the best way to remove/replace a list of special characters from titles when saving to disk/sending to device? I'd like to make sure certain characters like colons and commas aren't included and I don't like that Calibre defaults to replacing colons with an underscore. I'm not a coder so I'm kind of fumbling my way through this.
So far I've stumbled through some posts and the documentation to get the following to replace colons with nothing, but I'm not sure how to make it do the same for additional characters Code:
{title: re(":","")} By some miracle, I've come up with the following to do the above AND limit the file name length, so if the solution could be incorporated into this, that'd be even better. Code:
{title:'sublist(re($, ":", ""), 0, 8, " ")'} |
![]() |
![]() |
![]() |
#650 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,005
Karma: 1312724
Join Date: Aug 2015
Device: Kindle
|
Quote:
Code:
{title: re("[:\,]","")}
Code:
{title: re("[:\,;_]","")}
|
|
![]() |
![]() |
![]() |
#651 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Jul 2023
Device: Onyx Boox Poke 5, Nova 3
|
|
![]() |
![]() |
![]() |
#652 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Is there any functional difference between $$#timesread>#0 or $$#timesread>=#1?
Code:
program: status = readstatus(); times = $$#timesread; switch_if( status=='currentlyreading' && times>#0, 'Currently Rereading', status=='currentlyreading', 'Currently Reading', status=='toberead' && times>#0, 'To Be Reread', status=='toberead', 'To Be Read', status=='read', 'Read', status=='unread', 'Unread', status=='didnotfinish', 'Did Not Finish', '' ) |
![]() |
![]() |
![]() |
#653 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,427
Karma: 6083323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
You could even do Code:
! $$#timesread<=#0 ![]() |
|
![]() |
![]() |
![]() |
#654 | |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Just out of curiosity, I put this in the template tester:
Quote:
|
|
![]() |
![]() |
![]() |
#655 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,427
Karma: 6083323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
func = datetime.utcnow if assume_utc else datetime.now default = func().replace(day=15, hour=0, minute=0, second=0, microsecond=0, tzinfo=_utc_tz if assume_utc else _local_tz) As such, a missing month is the current local month and a missing day is the 15th. A missing time becomes midnight. I don't know if one can have a missing year, but if so then it would be the current year. |
|
![]() |
![]() |
![]() |
#656 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Code:
program: dates = list_count($#readdates, ','); readcount = $$#timesread; if dates != readcount then 'yes' fi |
![]() |
![]() |
![]() |
#657 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,427
Karma: 6083323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Because the string '0' (zero, list_count()) doesn't equal the string 'none' (raw_field()). If you used !=# then IIRC zero would equal none.
|
![]() |
![]() |
![]() |
#658 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,960
Karma: 55949477
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Ah yeah, adding a hash sign fixes that. Thanks.
|
![]() |
![]() |
![]() |
#659 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,005
Karma: 1312724
Join Date: Aug 2015
Device: Kindle
|
When writing a template function, is there a way to test whether the function is called from a python template or not? If so, can it return a python object (e.g. python list)? or would it result in an error?
|
![]() |
![]() |
![]() |
#660 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,427
Karma: 6083323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
I suggest you provide two functions, one that returns a string and one that returns whatever. Alternately, provide an optional parameter that tells the function what to return. Note that if a python template function returns a list then the formatter tries to convert the returned value to a string with ', '.join(returned_value). Of course this only works if the list contains strings. |
||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 87 | 10-31-2023 03:47 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 |