How to use the aqt.mw.col.decks.get function in aqt

To help you get started, we’ve selected a few aqt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github megachweng / Anki-Youdao / combined.py View on Github external
def syncYoudao(self, result):
        name = self.sync_to_lineEdit.text()
        deleted = result['deleted']
        terms = result['terms']
        cardID = []
        info_add = '0'
        info_delete = '0'

        if terms[0] is not None:
            deck = mw.col.decks.get(mw.col.decks.id(name))
            model = addCustomModel(name, mw.col)

            # assign custom model to new deck
            mw.col.decks.select(deck["id"])
            mw.col.decks.get(deck)["mid"] = model["id"]
            mw.col.decks.save(deck)

            # assign new deck to custom model
            mw.col.models.setCurrent(model)
            mw.col.models.current()["did"] = deck["id"]
            mw.col.models.save(model)

            for term in terms:
                note = mw.col.newNote()
                note["Front"] = term["term"]
                if term['definition'] is None:
                    term["definition"] = 'NULL'
                note["Back"] = term["definition"].replace('\n', '<br>')

                mw.col.addNote(note)
            mw.col.reset()
github megachweng / Anki-Youdao / combined.py View on Github external
def syncYoudao(self, result):
        name = self.sync_to_lineEdit.text()
        deleted = result['deleted']
        terms = result['terms']
        cardID = []
        info_add = '0'
        info_delete = '0'

        if terms[0] is not None:
            deck = mw.col.decks.get(mw.col.decks.id(name))
            model = addCustomModel(name, mw.col)

            # assign custom model to new deck
            mw.col.decks.select(deck["id"])
            mw.col.decks.get(deck)["mid"] = model["id"]
            mw.col.decks.save(deck)

            # assign new deck to custom model
            mw.col.models.setCurrent(model)
            mw.col.models.current()["did"] = deck["id"]
            mw.col.models.save(model)

            for term in terms:
                note = mw.col.newNote()
                note["Front"] = term["term"]
                if term['definition'] is None:
github megachweng / Dict2Anki / Dict2Anki / note.py View on Github external
def processNote(self, deckName):
        deck = mw.col.decks.get(mw.col.decks.id(deckName))

        # create custom model
        model = self.addCustomModel(deckName, mw.col)

        # assign custom model to new deck
        mw.col.decks.select(deck["id"])
        mw.col.decks.get(deck)["mid"] = model["id"]
        mw.col.decks.save(deck)

        # assign new deck to custom model
        mw.col.models.setCurrent(model)
        mw.col.models.current()["did"] = deck["id"]
        mw.col.models.save(model)

        # start creating notes
        if self.new:
            for term in self.new:
                note = mw.col.newNote()
                note['term'] = term['term']
                if term['definition']:
                    note['definition'] = term['definition']
                if term['uk']:
                    note['uk'] = term['uk']
github jre2 / JapaneseStudy / anki / plugins / morphman3 / morph / util.py View on Github external
def cfg( modelId, deckId, key ):
    assert cfgMod, 'Tried to use cfgMods before profile loaded'
    profile = mw.pm.name
    model = mw.col.models.get( modelId )[ 'name' ] if modelId else None
    deck = mw.col.decks.get( deckId )[ 'name' ] if deckId else None
    if key in cfgMod.deck_overrides.get( deck, [] ):
        return cfgMod.deck_overrides[ deck ][ key ]
    elif key in cfgMod.model_overrides.get( model, [] ):
        return cfgMod.model_overrides[ model ][ key ]
    elif key in cfgMod.profile_overrides.get( profile, [] ):
        return cfgMod.profile_overrides[ profile ][ key ]
    else:
        return cfgMod.default[ key ]
github hssm / SuperStyler / SuperStyler / SuperStyler / SuperStyler.py View on Github external
script = script.replace('##AddressGoesHere##', url)
        
        # Create the template that we will inject javascript into
        cardName = PREFIX + "-tmpl-" + strftime("%Y%m%d%H%M%S", gmtime())
        new_tmpl = mw.col.models.newTemplate(cardName)
        new_tmpl['qfmt'] = script + tmpl_q
        new_tmpl['afmt'] = script + tmpl_a
        
        # Add it to the model we selected
        mw.col.models.addTemplate(model, new_tmpl)
        mw.col.models.save(model, True)
                
        # Create a dynamic deck. This also sets it as the current deck
        deckName = PREFIX + "-deck-" + strftime("%Y%m%d%H%M%S", gmtime())
        dynDeckId = mw.col.decks.newDyn(deckName)
        dynDeck = mw.col.decks.get(dynDeckId)
        searchStr = "card:'%s'" % (cardName)
        dynDeck['delays'] = None
        dynDeck['terms'][0] =  [searchStr, 100, 0] #search, limit, current
        dynDeck['resched'] = True
        mw.col.decks.save(dynDeck)
        mw.col.sched.rebuildDyn(dynDeckId)
        
        # Redraw the card layout window to show the one we just created.
        # Also, select it.
        self.clayout.redraw()
        self.clayout.selectCard(new_tmpl['ord'])
        
        _tmpl_server.set_CSS(css)
        # Syncing can't be done with the CardLayout window open.
        # We close it, do our sync, then open it up again.
        self.clayout.reject()
github Pradhyo / anki-markdown-notes / anki-markdown.py View on Github external
def addNote(front, back, tag, model, deck, id=None):
    """
    Add note with `front` and `back` to `deck` using `model`.
    If `deck` doesn't exist, it is created.
    If `model` doesn't exist, nothing is done.
    If `id` is passed, it is used as the id
    """
    model = mw.col.models.byName(model)
    if model:
        mw.col.decks.current()['mid'] = model['id']
    else:
        return None

    # Creates or reuses deck with name passed using `deck`
    did = mw.col.decks.id(deck)
    deck = mw.col.decks.get(did)

    note = mw.col.newNote()
    note.model()['did'] = did

    note.fields[0] = front
    note.fields[1] = back

    if id:
        note.id = id
    note.addTag(tag)
    mw.col.addNote(note)
    mw.col.save()
    return note.id
github megachweng / Dict2Anki / Dict2Anki / note.py View on Github external
def processNote(self, deckName):
        deck = mw.col.decks.get(mw.col.decks.id(deckName))

        # create custom model
        model = self.addCustomModel(deckName, mw.col)

        # assign custom model to new deck
        mw.col.decks.select(deck["id"])
        mw.col.decks.get(deck)["mid"] = model["id"]
        mw.col.decks.save(deck)

        # assign new deck to custom model
        mw.col.models.setCurrent(model)
        mw.col.models.current()["did"] = deck["id"]
        mw.col.models.save(model)

        # start creating notes
        if self.new:
github luoliyan / incremental-reading / ir / importer.py View on Github external
return
            did = deck['id']
        else:
            did = mw.col.conf['curDeck']

        model = mw.col.models.byName(self.settings['modelName'])
        note = Note(mw.col, model)
        setField(note, self.settings['titleField'], title)
        setField(note, self.settings['textField'], text)
        setField(note, self.settings['sourceField'], source)
        if priority:
            setField(note, self.settings['prioField'], priority)
        note.model()['did'] = did
        mw.col.addNote(note)
        mw.deckBrowser.show()
        return mw.col.decks.get(did)['name']