From 9187c1e82bb76ddfd22f1d292852955af6fbcc33 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Jan 2016 09:33:17 +0530 Subject: [PATCH] Fix existing rating not being removed when using Polish Books or Embed Metadata tools on EPUB files. Fixes #1534597 [Polish Books not updating Ratings](https://bugs.launchpad.net/calibre/+bug/1534597) --- src/calibre/ebooks/metadata/opf2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index b12ea4b6c9..08aa439007 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -1276,9 +1276,9 @@ class OPF(object): # {{{ 'isbn', 'tags', 'category', 'comments', 'book_producer', 'pubdate', 'user_categories', 'author_link_map'): val = getattr(mi, attr, None) - is_null = val is None or val in ((), [], (None, None), {}) + 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'}: + if apply_null and attr in {'series', 'tags', 'isbn', 'comments', 'publisher', 'rating'}: setattr(self, attr, ([] if attr == 'tags' else None)) else: setattr(self, attr, val)