mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix setting rating via ebook-meta command line tool broken in calibre 5. Fixes #1901113 [ebook-meta --rating fails](https://bugs.launchpad.net/calibre/+bug/1901113)
More python 3 chicanery
This commit is contained in:
parent
4a864575b1
commit
b0e276435f
@ -1313,6 +1313,8 @@ class OPF(object): # {{{
|
||||
'isbn', 'tags', 'category', 'comments', 'book_producer',
|
||||
'pubdate', 'user_categories', 'author_link_map'):
|
||||
val = getattr(mi, attr, None)
|
||||
if attr == 'rating' and val:
|
||||
val = float(val)
|
||||
is_null = val is None or val in ((), [], (None, None), {}) or (attr == 'rating' and val < 0.1)
|
||||
if is_null:
|
||||
if apply_null and attr in {'series', 'tags', 'isbn', 'comments', 'publisher', 'rating'}:
|
||||
|
@ -744,7 +744,7 @@ def set_rating(root, prefixes, refines, val):
|
||||
if prop.lower() == pq:
|
||||
remove_element(meta, refines)
|
||||
if val:
|
||||
create_rating(root, prefixes, '%.2g' % val)
|
||||
create_rating(root, prefixes, '%.2g' % float(val))
|
||||
# }}}
|
||||
|
||||
# Series {{{
|
||||
@ -1052,7 +1052,7 @@ def apply_metadata(root, mi, cover_prefix='', cover_data=None, apply_null=False,
|
||||
set_publisher(root, prefixes, refines, mi.publisher)
|
||||
if ok('tags'):
|
||||
set_tags(root, prefixes, refines, mi.tags)
|
||||
if ok('rating') and mi.rating is not None and mi.rating > 0.1:
|
||||
if ok('rating') and mi.rating is not None and float(mi.rating) > 0.1:
|
||||
set_rating(root, prefixes, refines, mi.rating)
|
||||
if ok('series'):
|
||||
set_series(root, prefixes, refines, mi.series, mi.series_index or 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user