From 975c0699b79203173c719115d30fa22878b41450 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 5 Mar 2020 19:29:49 -0800 Subject: [PATCH] Fixes for old version of Anki, cleanup script --- link.sh | 13 ++++++++++++- link_mac.sh | 2 -- plugin/__init__.py | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) delete mode 100755 link_mac.sh diff --git a/link.sh b/link.sh index 9551068..7e7fe3c 100755 --- a/link.sh +++ b/link.sh @@ -1,2 +1,13 @@ #!/usr/bin/env bash -ln -s $(pwd)/plugin ~/.local/share/Anki2/addons21/AnkiConnectDev + +plugin_name=AnkiConnectDev +plugin_path_linux=~/.local/share/Anki2/addons21 +plugin_path_mac=~/Library/Application\ Support/Anki2/addons21 + +if [ -d "$plugin_path_linux" ]; then + ln -s -f $(pwd)/plugin $plugin_path_linux/$plugin_name +fi + +if [ -d "$plugin_path_mac" ]; then + ln -s -f $(pwd)/plugin $plugin_path_mac/$plugin_name +fi diff --git a/link_mac.sh b/link_mac.sh deleted file mode 100755 index 316966e..0000000 --- a/link_mac.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -ln -s $(pwd)/plugin ~/Library/Application\ Support/Anki2/addons21/AnkiConnectDev diff --git a/plugin/__init__.py b/plugin/__init__.py index 3579af4..cde266c 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -802,12 +802,22 @@ class AnkiConnect: name = info['name'] fields[name] = {'value': note.fields[order], 'order': order} + if getattr(card, 'question', None) is None: + question = card._getQA()['q'] + else: + question = card.question(), + + if getattr(card, 'answer', None) is None: + answer = card._getQA()['a'] + else: + answer = card.answer() + result.append({ 'cardId': card.id, 'fields': fields, 'fieldOrder': card.ord, - 'question': card.question(), - 'answer': card.answer(), + 'question': question, + 'answer': answer, 'modelName': model['name'], 'deckName': self.deckNameFromId(card.did), 'css': model['css'],