ebook-meta: fix an error when using an rmpty string as the rating on epub 2

This commit is contained in:
Kovid Goyal 2020-10-30 20:49:21 +05:30
parent b530b8313d
commit 0035170828
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1315,7 +1315,7 @@ class OPF(object): # {{{
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)
is_null = val is None or val in ((), [], (None, None), {}) or (attr == 'rating' and (not val or val < 0.1))
if is_null:
if apply_null and attr in {'series', 'tags', 'isbn', 'comments', 'publisher', 'rating'}:
setattr(self, attr, ([] if attr == 'tags' else None))