From e4adfb044056b175d258974e67c377bd12fde3e4 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 26 Jun 2011 21:05:54 -0400 Subject: [PATCH] Store: opensearch fix showing price. --- src/calibre/gui2/store/opensearch_store.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/store/opensearch_store.py b/src/calibre/gui2/store/opensearch_store.py index 456b6a7461..e7aa30a85c 100644 --- a/src/calibre/gui2/store/opensearch_store.py +++ b/src/calibre/gui2/store/opensearch_store.py @@ -67,7 +67,7 @@ class OpenSearchStore(StorePlugin): s = SearchResult() - s.detail_item = ''.join(data.xpath('./*[local-name() = "id"]/text()')) + s.detail_item = ''.join(data.xpath('./*[local-name() = "id"]/text()')).strip() for link in data.xpath('./*[local-name() = "link"]'): rel = link.get('rel') @@ -83,12 +83,20 @@ class OpenSearchStore(StorePlugin): if type: ext = mimetypes.guess_extension(type) if ext: - ext = ext[1:].upper() + ext = ext[1:].upper().strip() s.downloads[ext] = href - s.formats = ', '.join(s.downloads.keys()) + s.formats = ', '.join(s.downloads.keys()).strip() + + s.title = ' '.join(data.xpath('./*[local-name() = "title"]//text()')).strip() + s.author = ', '.join(data.xpath('./*[local-name() = "author"]//*[local-name() = "name"]//text()')).strip() + + price_e = data.xpath('.//*[local-name() = "price"][1]') + if price_e: + price_e = price_e[0] + currency_code = price_e.get('currencycode', '') + price = ''.join(price_e.xpath('.//text()')).strip() + s.price = currency_code + ' ' + price + s.price = s.price.strip() - s.title = ' '.join(data.xpath('./*[local-name() = "title"]//text()')) - s.author = ', '.join(data.xpath('./*[local-name() = "author"]//*[local-name() = "name"]//text()')) - s.price = ' '.join(data.xpath('.//*[local-name() = "price"]//text()')) yield s