~foosoft/anki-connect

a78d40457cb9aa06a1ef44ba1841675dee5fbf0e — David Bailey 7 years ago e808814
Change behaviour of tag/suspend functions

2 files changed, 20 insertions(+), 23 deletions(-)

M AnkiConnect.py
M README.md
M AnkiConnect.py => AnkiConnect.py +12 -15
@@ 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

M README.md => README.md +8 -8
@@ 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]
        }
    }
    ```

Do not follow this link