From 72e7d29690e4d7eb556ebbf7952a16208d3f5a69 Mon Sep 17 00:00:00 2001 From: David Forrester Date: Fri, 22 Nov 2013 00:06:06 +1100 Subject: [PATCH] Handle rating and numeric columns for Kobo shelves Kobo driver: Fix errors when using rating or numerical custom columns to create shelves. Fixes #1253637 [Kobo driver has error when rating column used for shelves](https://bugs.launchpad.net/calibre/+bug/1253637) Convert the category to string in case a numeric column is used. For a rating column, divide the value by two. --- src/calibre/devices/kobo/books.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/kobo/books.py b/src/calibre/devices/kobo/books.py index 5a76ec2f63..8fd82ce4f1 100644 --- a/src/calibre/devices/kobo/books.py +++ b/src/calibre/devices/kobo/books.py @@ -161,6 +161,8 @@ class KTCollectionsBookList(CollectionsBookList): # debug_print("KTCollectionsBookList:get_collections - val is list=", val) elif fm is not None and fm['datatype'] == 'series': val = [orig_val] + elif fm is not None and fm['datatype'] == 'rating': + val = [str(orig_val / 2)] elif fm is not None and fm['datatype'] == 'text' and fm['is_multiple']: if isinstance(orig_val, (list, tuple)): val = orig_val @@ -205,7 +207,7 @@ class KTCollectionsBookList(CollectionsBookList): if not category: continue - cat_name = category.strip(' ,') + cat_name = str(category).strip(' ,') if cat_name not in collections: collections[cat_name] = {}