本文整理匯總了Python中anki.decks.DeckManager.beforeUpload方法的典型用法代碼示例。如果您正苦於以下問題:Python DeckManager.beforeUpload方法的具體用法?Python DeckManager.beforeUpload怎麽用?Python DeckManager.beforeUpload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類anki.decks.DeckManager
的用法示例。
在下文中一共展示了DeckManager.beforeUpload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _Collection
# 需要導入模塊: from anki.decks import DeckManager [as 別名]
# 或者: from anki.decks.DeckManager import beforeUpload [as 別名]
#.........這裏部分代碼省略.........
if not self.db:
self.db = anki.db.DB(self.path)
self.media.connect()
def rollback(self):
self.db.rollback()
self.load()
self.lock()
def modSchema(self, check=True):
"Mark schema modified. Call this first so user can abort if necessary."
if not self.schemaChanged():
if check and not runFilter("modSchema", True):
raise AnkiError("abortSchemaMod")
self.scm = intTime(1000)
def schemaChanged(self):
"True if schema changed since last sync."
return self.scm > self.ls
def setDirty(self):
"Signal there are temp. suspended cards that need cleaning up on close."
self.dty = True
def cleanup(self):
"Unsuspend any temporarily suspended cards."
if self.dty:
self.sched.onClose()
self.dty = False
def usn(self):
return self._usn if self.server else -1
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):
示例2: _Collection
# 需要導入模塊: from anki.decks import DeckManager [as 別名]
# 或者: from anki.decks.DeckManager import beforeUpload [as 別名]
#.........這裏部分代碼省略.........
self.db.close()
self.db = None
self.media.close()
self._closeLog()
def reopen(self):
"Reconnect to DB (after changing threads, etc)."
import anki.db
if not self.db:
self.db = anki.db.DB(self.path)
self.media.connect()
self._openLog()
def rollback(self):
self.db.rollback()
self.load()
self.lock()
def modSchema(self, check):
"Mark schema modified. Call this first so user can abort if necessary."
if not self.schemaChanged():
if check and not runFilter("modSchema", True):
raise AnkiError("abortSchemaMod")
self.scm = intTime(1000)
self.setMod()
def schemaChanged(self):
"True if schema changed since last sync."
return self.scm > self.ls
def usn(self):
return self._usn if self.server else -1
def beforeUpload(self):
"Called before a full upload."
tbls = "notes", "cards", "revlog"
for t in tbls:
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)