From 2afb62c9f7b46c83b836f030e6a60414c5d8a8ba Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Wed, 22 Dec 2010 18:11:11 +0000 Subject: [PATCH] Another try at the special collection stuff --- src/calibre/devices/prs505/driver.py | 11 +++++++++-- src/calibre/devices/usbms/books.py | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index 23f59e4737..6652d581d4 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -58,9 +58,16 @@ class PRS505(USBMS): SUPPORTS_USE_AUTHOR_SORT = True EBOOK_DIR_MAIN = 'database/media/books' + ALL_BY_TITLE = _('All by title') + ALL_BY_AUTHOR = _('All by author') + EXTRA_CUSTOMIZATION_MESSAGE = _('Comma separated list of metadata fields ' 'to turn into collections on the device. Possibilities include: ')+\ - 'series, tags, authors' + 'series, tags, authors' +\ + _('. Two special collections are available: %s:%s and %s:%s. Add ' + 'these values to the list to enable them. The collections will be ' + 'given the name provided after the ":" character.')%( + 'abt', ALL_BY_TITLE, 'aba', ALL_BY_AUTHOR) EXTRA_CUSTOMIZATION_DEFAULT = ', '.join(['series', 'tags']) plugboard = None @@ -151,7 +158,7 @@ class PRS505(USBMS): blists[i] = booklists[i] opts = self.settings() if opts.extra_customization: - collections = [x.lower().strip() for x in + collections = [x.strip() for x in opts.extra_customization.split(',')] else: collections = [] diff --git a/src/calibre/devices/usbms/books.py b/src/calibre/devices/usbms/books.py index 84b8585d5c..a9c980c31b 100644 --- a/src/calibre/devices/usbms/books.py +++ b/src/calibre/devices/usbms/books.py @@ -134,14 +134,17 @@ class CollectionsBookList(BookList): collections = {} # get the special collection names - try: - all_by_author = tweaks['device_special_collections']['author'] - except: - all_by_author = '' - try: - all_by_title = tweaks['device_special_collections']['title'] - except: - all_by_title = '' + all_by_author = '' + all_by_title = '' + ca = [] + for c in collection_attributes: + if c.startswith('aba:') and c[4:]: + all_by_author = c[4:] + elif c.startswith('abt:') and c[4:]: + all_by_title = c[4:] + else: + ca.append(c.lower()) + collection_attributes = ca for book in self: tsval = book.get('_pb_title_sort',