From 2e8734dd79c1e4490f737c9801f6f2d1c842adb2 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 7 May 2016 18:24:51 -0700 Subject: [PATCH] WIP --- yomi_base/anki_connect.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/yomi_base/anki_connect.py b/yomi_base/anki_connect.py index ed7dee5..fa1e719 100644 --- a/yomi_base/anki_connect.py +++ b/yomi_base/anki_connect.py @@ -35,7 +35,6 @@ class AnkiConnect: self.handlers = { 'addNote': self.apiAddNote, - 'canAddNote': self.apiCanAddNote, 'canAddNotes': self.apiCanAddNotes, 'getVersion': self.apiGetVersion, } @@ -100,26 +99,18 @@ class AnkiConnect: return self.anki.addNote(args['deck'], args['model'], args['fields'], args['tags']) - def apiCanAddNote(self, params): - args = self.prepareNoteArgs(params.get('definition'), params.get('mode')) - if args is not None: - return self.anki.canAddNote(args['deck'], args['model'], args['fields']) - - def apiCanAddNotes(self, params): - results = [] - for definition in params: - state = {} - results.append(state) - for mode in ['vocabExp', 'vocabReading', 'kanji']: - args = self.prepareNoteArgs(definition, mode) - state[mode] = args is not None and self.anki.canAddNote( - args['deck'], - args['model'], - args['fields'] - ) + states = [] - return results + for definition in params.get('definitions', []): + state = {} + for mode in params.get('modes', []): + args = self.prepareNoteArgs(definition, mode) + state[mode] = args is not None and self.anki.canAddNote(args['deck'], args['model'], args['fields']) + + states.append(state) + + return states def apiGetVersion(self, params):