Skip to content

Commit

Permalink
cardName can be None, ref #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Aug 4, 2023
1 parent 7aa240e commit 0618e99
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 252 deletions.
6 changes: 4 additions & 2 deletions calibre-plugin/dialog/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ def __init__(self, card, library, tab, *args, **kwargs):

# Card Name
card_name = (
card["cardName"] if not DEMO_MODE else obfuscate_name(card["cardName"])
)
card["cardName"]
if not DEMO_MODE
else obfuscate_name(card["cardName"] or "")
) or ""
card_lbl = ClickableQLabel("<b>" + _("Card name") + "</b>: " + card_name)
card_lbl.setTextFormat(Qt.RichText)
card_lbl.doubleClicked.connect(
Expand Down
4 changes: 2 additions & 2 deletions calibre-plugin/dialog/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def search_results_view_context_menu_requested(self, pos):
card_action = menu.addAction(
QIcon(self.get_card_pixmap(site["__library"])),
truncate_for_display(
f'{card["advantageKey"]}: {card["cardName"]}'
f'{card["advantageKey"]}: {card["cardName"] or ""}'
),
)
card_action.setToolTip(self.borrow_tooltip(media, site))
Expand Down Expand Up @@ -316,7 +316,7 @@ def search_results_view_context_menu_requested(self, pos):
card_action = menu.addAction(
QIcon(self.get_card_pixmap(site["__library"])),
truncate_for_display(
f'{card["advantageKey"]}: {card["cardName"]}'
f'{card["advantageKey"]}: {card["cardName"] or ""}'
),
)
card_action.setToolTip(self.hold_tooltip(media, site))
Expand Down
10 changes: 7 additions & 3 deletions calibre-plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ def data(self, index, role):
if role != Qt.DisplayRole:
return None
if col == 0:
return truncate_for_display(f'{card["advantageKey"]}: {card["cardName"]}')
return truncate_for_display(
f'{card["advantageKey"]}: {card["cardName"] or ""}'
)
return None


Expand Down Expand Up @@ -619,7 +621,7 @@ def data(self, index, role):
card = self.get_card(subscription["cardId"])
if not card:
return "Invalid card setup"
return f'{card["advantageKey"]}: {card["cardName"]}'
return f'{card["advantageKey"]}: {card["cardName"] or ""}'
# DisplayRole, DisplaySortRole
if role not in (Qt.DisplayRole, LibbyModel.DisplaySortRole):
return None
Expand All @@ -636,7 +638,9 @@ def data(self, index, role):
card = self.get_card(subscription["cardId"])
if not card:
return "Invalid card setup"
return truncate_for_display(f'{card["advantageKey"]}: {card["cardName"]}')
return truncate_for_display(
f'{card["advantageKey"]}: {card["cardName"] or ""}'
)
if col == 3:
is_borrowed = subscription.get("__is_borrowed")
if role == LibbyModel.DisplaySortRole:
Expand Down
98 changes: 49 additions & 49 deletions calibre-plugin/translations/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libby-calibre-plugin 0.1.6\n"
"Report-Msgid-Bugs-To: https://github.com/ping/libby-calibre-plugin/\n"
"POT-Creation-Date: 2023-08-04 23:11+0800\n"
"POT-Creation-Date: 2023-08-05 00:09+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -22,7 +22,7 @@ msgstr ""
msgid "Import loans from your OverDrive Libby account"
msgstr ""

#: calibre-plugin/action.py:51 calibre-plugin/config.py:139
#: calibre-plugin/action.py:51 calibre-plugin/config.py:140
msgid "Libby"
msgstr ""

Expand All @@ -34,122 +34,122 @@ msgstr ""
msgid "Borrowing"
msgstr ""

#: calibre-plugin/config.py:74 calibre-plugin/config.py:418
#: calibre-plugin/config.py:75 calibre-plugin/config.py:421
msgid "Libby Setup Code"
msgstr ""

#: calibre-plugin/config.py:75
#: calibre-plugin/config.py:76
msgid "8-digit setup code"
msgstr ""

#: calibre-plugin/config.py:76
#: calibre-plugin/config.py:77
msgid "Hide Magazines"
msgstr ""

#: calibre-plugin/config.py:77
#: calibre-plugin/config.py:78
msgid "Hide Ebooks"
msgstr ""

#: calibre-plugin/config.py:78
#: calibre-plugin/config.py:79
msgid "Hide titles already in library"
msgstr ""

#: calibre-plugin/config.py:79
#: calibre-plugin/config.py:80
msgid "Exclude empty books when hiding titles already in library"
msgstr ""

#: calibre-plugin/config.py:80
#: calibre-plugin/config.py:81
msgid "Hide unavailable holds"
msgstr ""

#: calibre-plugin/config.py:81
#: calibre-plugin/config.py:82
msgid "Prefer Open Formats"
msgstr ""

#: calibre-plugin/config.py:82
#: calibre-plugin/config.py:83
msgid "Tag downloaded ebooks with"
msgstr ""

#: calibre-plugin/config.py:83
#: calibre-plugin/config.py:84
msgid "Example: library,books"
msgstr ""

#: calibre-plugin/config.py:84
#: calibre-plugin/config.py:85
msgid "Tag downloaded magazines with"
msgstr ""

#: calibre-plugin/config.py:85
#: calibre-plugin/config.py:86
msgid "Example: library,magazines"
msgstr ""

#: calibre-plugin/config.py:86
#: calibre-plugin/config.py:87
msgid "Always confirm returns"
msgstr ""

#: calibre-plugin/config.py:87
#: calibre-plugin/config.py:88
msgid "Always confirm holds cancellation"
msgstr ""

#: calibre-plugin/config.py:88
#: calibre-plugin/config.py:89
msgid "Enable OverDrive Link Plugin integration"
msgstr ""

#: calibre-plugin/config.py:89
#: calibre-plugin/config.py:90
msgid "Mark updated books"
msgstr ""

#: calibre-plugin/config.py:90
#: calibre-plugin/config.py:91
msgid "Always download as a new book"
msgstr ""

#: calibre-plugin/config.py:91
#: calibre-plugin/config.py:92
msgid "Connection timeout"
msgstr ""

#: calibre-plugin/config.py:93
#: calibre-plugin/config.py:94
msgid "Maximum search results"
msgstr ""

#: calibre-plugin/config.py:94
#: calibre-plugin/config.py:95
#, python-brace-format
msgid "Library Keys (comma-separated, max: {n})"
msgstr ""

#: calibre-plugin/config.py:146
#: calibre-plugin/config.py:147
msgid "Libby is configured."
msgstr ""

#: calibre-plugin/config.py:148 calibre-plugin/dialog/base.py:252
#: calibre-plugin/config.py:149 calibre-plugin/dialog/base.py:252
msgid "Libby is not configured yet."
msgstr ""

#: calibre-plugin/config.py:179 calibre-plugin/dialog/cards.py:178
#: calibre-plugin/dialog/cards.py:230 calibre-plugin/dialog/loans.py:154
#: calibre-plugin/config.py:180 calibre-plugin/dialog/cards.py:180
#: calibre-plugin/dialog/cards.py:232 calibre-plugin/dialog/loans.py:154
msgid "Loans"
msgstr ""

#: calibre-plugin/config.py:273 calibre-plugin/dialog/cards.py:200
#: calibre-plugin/dialog/cards.py:241 calibre-plugin/dialog/holds.py:155
#: calibre-plugin/config.py:274 calibre-plugin/dialog/cards.py:202
#: calibre-plugin/dialog/cards.py:243 calibre-plugin/dialog/holds.py:155
#: calibre-plugin/dialog/holds.py:169
msgid "Holds"
msgstr ""

#: calibre-plugin/config.py:298
#: calibre-plugin/config.py:299
msgid "Search"
msgstr ""

#: calibre-plugin/config.py:316
#, python-brace-format
msgid ""
"Up to {n} libraries, comma-separated. Use the Cards tab to get the library "
"key codes. Example: lapl,sno-isle,livebrary,kcls"
"Up to {n} libraries, comma-separated. View your library key codes from the "
"Cards tab. Example: lapl,sno-isle,livebrary,kcls"
msgstr ""

#: calibre-plugin/config.py:328
#: calibre-plugin/config.py:331
msgid "Network"
msgstr ""

#: calibre-plugin/config.py:419
#: calibre-plugin/config.py:422
#, python-brace-format
msgid "Invalid setup code format: {code}"
msgstr ""
Expand Down Expand Up @@ -239,7 +239,7 @@ msgid "Expire Date"
msgstr ""

#: calibre-plugin/models.py:173 calibre-plugin/models.py:333
#: calibre-plugin/models.py:659 calibre-plugin/dialog/cards.py:219
#: calibre-plugin/models.py:663 calibre-plugin/dialog/cards.py:221
msgid "Library"
msgstr ""

Expand Down Expand Up @@ -283,15 +283,15 @@ msgstr ""
msgid "Suspended Hold"
msgstr ""

#: calibre-plugin/models.py:543
#: calibre-plugin/models.py:545
msgid "Release Date"
msgstr ""

#: calibre-plugin/models.py:543
#: calibre-plugin/models.py:545
msgid "Library Card"
msgstr ""

#: calibre-plugin/models.py:543
#: calibre-plugin/models.py:545
msgid "Borrowed"
msgstr ""

Expand Down Expand Up @@ -342,46 +342,46 @@ msgstr ""
msgid "Check your connection or retry in a few minutes."
msgstr ""

#: calibre-plugin/dialog/cards.py:108 calibre-plugin/dialog/cards.py:192
#: calibre-plugin/dialog/cards.py:214
#: calibre-plugin/dialog/cards.py:108 calibre-plugin/dialog/cards.py:194
#: calibre-plugin/dialog/cards.py:216
msgid "Right-click for shortcuts"
msgstr ""

#: calibre-plugin/dialog/cards.py:116
#: calibre-plugin/dialog/cards.py:118
msgid "Card name"
msgstr ""

#: calibre-plugin/dialog/cards.py:129
#: calibre-plugin/dialog/cards.py:131
msgid "Username/Card number"
msgstr ""

#: calibre-plugin/dialog/cards.py:142
#: calibre-plugin/dialog/cards.py:144
msgid "Created date"
msgstr ""

#: calibre-plugin/dialog/cards.py:161
#: calibre-plugin/dialog/cards.py:163
msgid "Verified date"
msgstr ""

#: calibre-plugin/dialog/cards.py:220 calibre-plugin/dialog/cards.py:231
#: calibre-plugin/dialog/cards.py:242 calibre-plugin/dialog/holds.py:259
#: calibre-plugin/dialog/cards.py:222 calibre-plugin/dialog/cards.py:233
#: calibre-plugin/dialog/cards.py:244 calibre-plugin/dialog/holds.py:259
#: calibre-plugin/dialog/loans.py:188 calibre-plugin/dialog/magazines.py:260
#: calibre-plugin/dialog/search.py:207
msgid "View in Libby"
msgstr ""

#: calibre-plugin/dialog/cards.py:223 calibre-plugin/dialog/cards.py:234
#: calibre-plugin/dialog/cards.py:245 calibre-plugin/dialog/holds.py:264
#: calibre-plugin/dialog/cards.py:225 calibre-plugin/dialog/cards.py:236
#: calibre-plugin/dialog/cards.py:247 calibre-plugin/dialog/holds.py:264
#: calibre-plugin/dialog/loans.py:193 calibre-plugin/dialog/magazines.py:265
#: calibre-plugin/dialog/search.py:233
msgid "View in OverDrive"
msgstr ""

#: calibre-plugin/dialog/cards.py:305 calibre-plugin/dialog/loans.py:72
#: calibre-plugin/dialog/cards.py:307 calibre-plugin/dialog/loans.py:72
msgid "Get latest loans"
msgstr ""

#: calibre-plugin/dialog/cards.py:319
#: calibre-plugin/dialog/cards.py:321
msgid "Cards"
msgstr ""

Expand Down
Loading

0 comments on commit 0618e99

Please sign in to comment.