From a78d40457cb9aa06a1ef44ba1841675dee5fbf0e Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 3 Aug 2017 22:21:59 +0100 Subject: [PATCH] Change behaviour of tag/suspend functions --- AnkiConnect.py | 27 ++++++++++++--------------- README.md | 16 ++++++++-------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index 82798a8..a09006e 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -375,18 +375,15 @@ class AnkiBridge: return note - def addTags(self, query, tags, add=True): - notes = aqt.mw.col.findNotes(query) + def addTags(self, notes, tags, add=True): aqt.mw.col.tags.bulkAdd(notes, tags, add) - def suspend(self, query, suspend=True): - cards = aqt.mw.col.findCards(query) + def suspend(self, cards, suspend=True): if suspend: - suspendFunction = aqt.mw.col.sched.suspendCards + aqt.mw.col.sched.suspendCards(cards) else: - suspendFunction = aqt.mw.col.sched.unsuspendCards - suspendFunction(cards) + aqt.mw.col.sched.unsuspendCards(cards) def startEditing(self): @@ -677,23 +674,23 @@ class AnkiConnect: @webApi - def addTags(self, query, tags, add=True): - return self.anki.addTags(query, tags, add) + def addTags(self, notes, tags, add=True): + return self.anki.addTags(notes, tags, add) @webApi - def removeTags(self, query, tags): - return self.anki.addTags(query, tags, False) + def removeTags(self, notes, tags): + return self.anki.addTags(notes, tags, False) @webApi - def suspend(self, query, suspend=True): - return self.anki.suspend(query, suspend) + def suspend(self, cards, suspend=True): + return self.anki.suspend(cards, suspend) @webApi - def unsuspend(self, query): - return self.anki.suspend(query, False) + def unsuspend(self, cards): + return self.anki.suspend(cards, False) @webApi diff --git a/README.md b/README.md index b0ba8f5..cc003ba 100644 --- a/README.md +++ b/README.md @@ -307,14 +307,14 @@ Below is a list of currently supported actions. Requests with invalid actions or * **addTags** - Adds tags to notes matching a query (same syntax as **browse**/**guiBrowse**). + Adds tags to notes by note ID. *Sample request*: ``` { "action": "addTags", "params": { - "query": "deck:French or deck:Spanish", + "notes": [1483959289817, 1483959291695], "tags": "european-languages" } } @@ -327,14 +327,14 @@ Below is a list of currently supported actions. Requests with invalid actions or * **removeTags** - Remove tags from notes matching a query (same syntax as **browse**/**guiBrowse**). + Remove tags from notes by note ID. *Sample request*: ``` { "action": "removeTags", "params": { - "query": "deck:Japanese or deck:Chinese", + "notes": [1483959289817, 1483959291695], "tags": "european-languages" } } @@ -347,14 +347,14 @@ Below is a list of currently supported actions. Requests with invalid actions or * **suspend** - Suspend cards matching a query (same syntax as **browse**/**guiBrowse**). + Suspend cards by card ID. *Sample request*: ``` { "action": "suspend", "params": { - "query": "tag:difficult" + "cards": [1483959291685, 1483959293217] } } ``` @@ -366,14 +366,14 @@ Below is a list of currently supported actions. Requests with invalid actions or * **unsuspend** - Unsuspend cards matching a query (same syntax as **browse**/**guiBrowse**). + Unsuspend cards by card ID. *Sample request*: ``` { "action": "unsuspend", "params": { - "query": "tag:easy" + "cards": [1483959291685, 1483959293217] } } ```