本文整理汇总了Python中anki.sched.Scheduler.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.reset方法的具体用法?Python Scheduler.reset怎么用?Python Scheduler.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anki.sched.Scheduler
的用法示例。
在下文中一共展示了Scheduler.reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _Collection
# 需要导入模块: from anki.sched import Scheduler [as 别名]
# 或者: from anki.sched.Scheduler import reset [as 别名]
#.........这里部分代码省略.........
self.db.execute("update %s set usn=0 where usn=-1" % t)
# we can save space by removing the log of deletions
self.db.execute("delete from graves")
self._usn += 1
self.models.beforeUpload()
self.tags.beforeUpload()
self.decks.beforeUpload()
self.modSchema(check=False)
self.ls = self.scm
# ensure db is compacted before upload
self.db.execute("vacuum")
self.db.execute("analyze")
self.close()
# Object creation helpers
##########################################################################
def getCard(self, id):
return anki.cards.Card(self, id)
def getNote(self, id):
return anki.notes.Note(self, id=id)
# Utils
##########################################################################
def nextID(self, type, inc=True):
type = "next"+type.capitalize()
id = self.conf.get(type, 1)
if inc:
self.conf[type] = id+1
return id
def reset(self):
"Rebuild the queue and reload data after DB modified."
self.sched.reset()
# Deletion logging
##########################################################################
def _logRem(self, ids, type):
self.db.executemany("insert into graves values (%d, ?, %d)" % (
self.usn(), type), ([x] for x in ids))
# Notes
##########################################################################
def noteCount(self):
return self.db.scalar("select count() from notes")
def newNote(self, forDeck=True):
"Return a new note with the current model."
return anki.notes.Note(self, self.models.current(forDeck))
def addNote(self, note):
"Add a note to the collection. Return number of new cards."
# check we have card models available, then save
cms = self.findTemplates(note)
if not cms:
return 0
note.flush()
# deck conf governs which of these are used
due = self.nextID("pos")
# add cards
ncards = 0
for template in cms:
示例2: _Collection
# 需要导入模块: from anki.sched import Scheduler [as 别名]
# 或者: from anki.sched.Scheduler import reset [as 别名]
#.........这里部分代码省略.........
def beforeUpload(self):
"Called before a full upload."
tbls = "notes", "cards", "revlog", "graves"
for t in tbls:
self.db.execute("update %s set usn=0 where usn=-1" % t)
self._usn += 1
self.models.beforeUpload()
self.tags.beforeUpload()
self.decks.beforeUpload()
self.modSchema()
self.ls = self.scm
self.close()
# Object creation helpers
##########################################################################
def getCard(self, id):
return anki.cards.Card(self, id)
def getNote(self, id):
return anki.notes.Note(self, id=id)
# Utils
##########################################################################
def nextID(self, type, inc=True):
type = "next"+type.capitalize()
id = self.conf.get(type, 1)
if inc:
self.conf[type] = id+1
return id
def reset(self):
"Rebuild the queue and reload data after DB modified."
self.sched.reset()
# Deletion logging
##########################################################################
def _logRem(self, ids, type):
self.db.executemany("insert into graves values (%d, ?, %d)" % (
self.usn(), type), ([x] for x in ids))
# Notes
##########################################################################
def noteCount(self):
return self.db.scalar("select count() from notes")
def newNote(self):
"Return a new note with the current model."
return anki.notes.Note(self, self.models.current())
def addNote(self, note):
"Add a note to the collection. Return number of new cards."
# check we have card models available, then save
cms = self.findTemplates(note)
if not cms:
return 0
note.flush()
# deck conf governs which of these are used
due = self.nextID("pos")
# add cards
ncards = 0
for template in cms: