本文整理汇总了Python中anki.models.ModelManager._updateRequired方法的典型用法代码示例。如果您正苦于以下问题:Python ModelManager._updateRequired方法的具体用法?Python ModelManager._updateRequired怎么用?Python ModelManager._updateRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anki.models.ModelManager
的用法示例。
在下文中一共展示了ModelManager._updateRequired方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _Collection
# 需要导入模块: from anki.models import ModelManager [as 别名]
# 或者: from anki.models.ModelManager import _updateRequired [as 别名]
#.........这里部分代码省略.........
select 1 from cards where ord not in %s and nid in (
select id from notes where mid = ?) limit 1""" %
ids2str([t['ord'] for t in m['tmpls']]),
m['id']):
return
return True
def fixIntegrity(self):
"Fix possible problems and rebuild caches."
problems = []
self.save()
oldSize = os.stat(self.path)[stat.ST_SIZE]
if self.db.scalar("pragma integrity_check") != "ok":
return (_("Collection is corrupt. Please see the manual."), False)
# note types with a missing model
ids = self.db.list("""
select id from notes where mid not in """ + ids2str(self.models.ids()))
if ids:
problems.append(
ngettext("Deleted %d note with missing note type.",
"Deleted %d notes with missing note type.", len(ids))
% len(ids))
self.remNotes(ids)
# for each model
for m in self.models.all():
for t in m['tmpls']:
if t['did'] == "None":
t['did'] = None
problems.append(_("Fixed AnkiDroid deck override bug."))
self.models.save(m)
if m['type'] == MODEL_STD:
# model with missing req specification
if 'req' not in m:
self.models._updateRequired(m)
problems.append(_("Fixed note type: %s") % m['name'])
# cards with invalid ordinal
ids = self.db.list("""
select id from cards where ord not in %s and nid in (
select id from notes where mid = ?)""" %
ids2str([t['ord'] for t in m['tmpls']]),
m['id'])
if ids:
problems.append(
ngettext("Deleted %d card with missing template.",
"Deleted %d cards with missing template.",
len(ids)) % len(ids))
self.remCards(ids)
# notes with invalid field count
ids = []
for id, flds in self.db.execute(
"select id, flds from notes where mid = ?", m['id']):
if (flds.count("\x1f") + 1) != len(m['flds']):
ids.append(id)
if ids:
problems.append(
ngettext("Deleted %d note with wrong field count.",
"Deleted %d notes with wrong field count.",
len(ids)) % len(ids))
self.remNotes(ids)
# delete any notes with missing cards
ids = self.db.list("""
select id from notes where id not in (select distinct nid from cards)""")
if ids:
cnt = len(ids)
problems.append(
ngettext("Deleted %d note with no cards.",