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 03-22-2024, 07:48 PM   #661
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,755
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
format_date and partial dates

I'm using this template to display a list of dates formatted as 'yyyy-MM-dd' as 'MMM d yyyy':

Code:
program:

	new_dates = '';

	for dates in '#datesread':
		converted = format_date(dates, 'MMM d yyyy');
		new_dates = list_union(new_dates, converted, ',')
	rof
However, several entries are just a year; e.g. '2017, 2023-06-13.' When I run them through this template, it ends up filling in the rest of the date so it becomes 2017-03-15.

What should I do here to get '2017, Jun 13 2023'? Alternately, I'd be fine removing the partial dates.

Last edited by ownedbycats; 03-22-2024 at 10:04 PM.
ownedbycats is offline   Reply With Quote
Old 03-23-2024, 09:20 AM   #662
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,765
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
format_date and partial dates

I'm using this template to display a list of dates formatted as 'yyyy-MM-dd' as 'MMM d yyyy':

Code:
program:

	new_dates = '';

	for dates in '#datesread':
		converted = format_date(dates, 'MMM d yyyy');
		new_dates = list_union(new_dates, converted, ',')
	rof
However, several entries are just a year; e.g. '2017, 2023-06-13.' When I run them through this template, it ends up filling in the rest of the date so it becomes 2017-03-15.

What should I do here to get '2017, Jun 13 2023'? Alternately, I'd be fine removing the partial dates.
The format_date() function expects a date. A year by itself isn't a date, so calibre's parse_date() makes it into one by using the 15th day of the current month. This isn't going to change.

You don't say if you can have a date like '2020-05'. Assuming you can, a variation of this template might give you what you want.
Code:
program:

	new_dates = '';

	for dates in '2020, 2021-05, 2022-03-10':
		if list_count(dates,'-') ==# 3 then
			converted = format_date(dates, 'MMM d yyyy')
		elif '-' in dates then
			converted = re(format_date(dates, 'MMM d yyyy'), ' 15 ', ' ')
		else
			converted = dates
		fi;
		new_dates = list_union(new_dates, converted, ',')
	rof
It gives the answer
Code:
Mar 10 2022, May 2021, 2020
chaley is offline   Reply With Quote
Advert
Old 03-23-2024, 01:20 PM   #663
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,755
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have only yyyy and yyyy-mm-dd, but that template worked on all the books I tested.

I didn't think of using a list_count with a - separator.
ownedbycats is offline   Reply With Quote
Old 05-11-2024, 08:37 PM   #664
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
A template has stopped working.
I was using the formula from this thread https://www.mobileread.com/forums/sh...&postcount=574

Code:
python:
def evaluate(book, context):
	vals = context.funcs.book_values('#ranking', 'title:true', '&', 0).split('&')
	vals = sorted([float(v) for v in vals], reverse=True)
	return str(1 + vals.index(float(book.get('#ranking'))))

to calculate the ranking position and now it says that there is an error on line 4
Give me a hand with the solution
dunhill is offline   Reply With Quote
Old 05-11-2024, 08:40 PM   #665
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,765
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
A template has stopped working.
I was using the formula from this thread https://www.mobileread.com/forums/sh...&postcount=574

Code:
python:
def evaluate(book, context):
	vals = context.funcs.book_values('#ranking', 'title:true', '&', 0).split('&')
	vals = sorted([float(v) for v in vals], reverse=True)
	return str(1 + vals.index(float(book.get('#ranking'))))

to calculate the ranking position and now it says that there is an error on line 4
Give me a hand with the solution
It would be helpful if you provided the actual error message.

Edit: an error will be thrown if #ranking contains something that isn't a number

Last edited by chaley; 05-11-2024 at 08:44 PM.
chaley is offline   Reply With Quote
Advert
Old 05-11-2024, 09:13 PM   #666
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
It would be helpful if you provided the actual error message.

Edit: an error will be thrown if #ranking contains something that isn't a number
I leave you screenshots
The personal column #grecuento
and the template
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	32
Size:	59.8 KB
ID:	208201   Click image for larger version

Name:	2.png
Views:	26
Size:	33.0 KB
ID:	208202   Click image for larger version

Name:	3.png
Views:	21
Size:	6.5 KB
ID:	208203  

Last edited by dunhill; 05-11-2024 at 09:15 PM.
dunhill is offline   Reply With Quote
Old 05-12-2024, 12:57 AM   #667
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,765
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
I leave you screenshots
The personal column #grecuento
and the template
Again, the actual error message is needed.

Note that line 4 will fail of the composite template returns something that isn't a number, for example the empty string.
chaley is offline   Reply With Quote
Old 05-12-2024, 09:14 AM   #668
claracurie
Junior Member
claracurie began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Sep 2020
Device: Fire 7
Hi, everyone!

I'm a total noob but I want to make a template for a composite column that takes the number of Goodreads' votes in the #grvotes column and adds 'thousand separators' to them, so that, for example, instead of 1678234 it shows 1,678,234.

I've been trying this
Code:
{#grvotes:format_number({0:#,##})}
But instead adds a decimal point and a trailing zero like this: 1678234,0

Could you help me?
claracurie is offline   Reply With Quote
Old 05-12-2024, 12:23 PM   #669
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
Again, the actual error message is needed.

Note that line 4 will fail of the composite template returns something that isn't a number, for example the empty string.
If we see the capture of grvotes ids it says 410
The real error is described in the first image:
Exception:Error in function <listcomp> on line 4: ValueError could not convert string to float: "

The strange thing is that it used to work fine.



I really don't know what happened but it was solved by redownloading or updating metadata, I was really worried. As always, I appreciate the help always received.
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	19
Size:	105.7 KB
ID:	208223  

Last edited by dunhill; 05-12-2024 at 12:46 PM.
dunhill is offline   Reply With Quote
Old 05-12-2024, 01:03 PM   #670
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,765
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
If we see the capture of grvotes ids it says 410
The real error is described in the first image:
Exception:Error in function <listcomp> on line 4: ValueError could not convert string to float: "

The strange thing is that it used to work fine.



I really don't know what happened but it was solved by redownloading or updating metadata, I was really worried. As always, I appreciate the help always received.
Sorry that I didn't see the error. It says that the votes for the book was the empty string, which can't be converted to a float. Is an empty or missing grvotes id something that shouldn't happen? It seems to me that it will always happen for new books. Updating metadata would fix that. The template can be changed to detect a missing id and do something else.

And you are welcome.
chaley is offline   Reply With Quote
Old 05-12-2024, 03:31 PM   #671
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
Sorry that I didn't see the error. It says that the votes for the book was the empty string, which can't be converted to a float. Is an empty or missing grvotes id something that shouldn't happen? It seems to me that it will always happen for new books. Updating metadata would fix that. The template can be changed to detect a missing id and do something else.

And you are welcome.
You say that a type of alert could be added to the form in case of data not found?
I appreciate your offer, but I wouldn't want to waste your time.
When uploading a new book to my personal library of almost 500 books.
I usually load everything that depends on a template.
The error may have been that I accidentally deleted a value, leaving it at zero or without data.

Last edited by dunhill; 05-12-2024 at 03:34 PM.
dunhill is offline   Reply With Quote
Old 05-16-2024, 09:01 AM   #672
vyrmin
Junior Member
vyrmin began at the beginning.
 
Posts: 2
Karma: 10
Join Date: May 2024
Device: Kobo Libra 2
Question Dozens of TypeError popups when searching for books in "get books"

Hi, sorry if this is the wrong place to post, I've searched in the forum for a bit and couldn't find something regarding this specific problem I have.

Whenever I open the get books section and search for books using a keyword, I get a lot of pop-ups displaying the following error message:

Code:
calibre, version 6.13.0
ERROR: Unhandled exception: <b>TypeError</b>:expected string or bytes-like object, got 'NoneType'

calibre 6.13  embedded-python: False
Linux-6.1.0-20-amd64-x86_64-with-glibc2.36 Linux ('64bit', 'ELF')
('Linux', '6.1.0-20-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11)')
Python 3.11.2
Interface language: None
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/gui2/store/search/search.py", line 387, in get_results
    self.results_view.model().add_result(res, store_plugin)
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 97, in add_result
    self._filter_results()
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 119, in _filter_results
    self.sort(self.sort_col, self.sort_order, False)
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 291, in sort
    self.all_matches.sort(
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 292, in <lambda>
    key=lambda x: sort_key(str(self.data_as_text(x, col))),
                               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 263, in data_as_text
    text = comparable_price(result.price)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 24, in comparable_price
    match = re.search(r'(?:\d|[,.](?=\d))(?:\d*(?:[,.\' ](?=\d))?)+', text)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/re/__init__.py", line 176, in search
    return _compile(pattern, flags).search(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
This does not occur when I only select archive.org and feedbooks as a source, so maybe it has a problem with certain stores only? I could do a binary search to find the broken stores, but maybe I'm just missing dependencies? Obviously, there is a problem with python, but it also refers to patterns and what I assume to be search syntax.

Thanks a lot in advance and please remove this post in case it is a duplicate or in the wrong place.
vyrmin is offline   Reply With Quote
Old 05-16-2024, 09:21 AM   #673
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You are using a distro package uninstall and install the official calibre binaries and you should be fine.
kovidgoyal is offline   Reply With Quote
Old 05-16-2024, 09:57 AM   #674
vyrmin
Junior Member
vyrmin began at the beginning.
 
Posts: 2
Karma: 10
Join Date: May 2024
Device: Kobo Libra 2
Talking

Quote:
Originally Posted by kovidgoyal View Post
You are using a distro package uninstall and install the official calibre binaries and you should be fine.
Thanks a lot, it worked
vyrmin is offline   Reply With Quote
Old 05-16-2024, 07:26 PM   #675
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,755
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
For an Action Chains copy-to-clipboard, how do I insert a line break into a strcat?
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 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 08:25 AM.


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