mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
identify whether it's a dupe or empty
This commit is contained in:
parent
1235f8362a
commit
c0e2a0ba50
1 changed files with 3 additions and 3 deletions
|
@ -132,17 +132,17 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
def dupeOrEmpty(self):
|
def dupeOrEmpty(self):
|
||||||
"True if first field is a duplicate or is empty."
|
"1 if first is empty; 2 if first is a duplicate, False otherwise."
|
||||||
val = self.fields[0]
|
val = self.fields[0]
|
||||||
if not val.strip():
|
if not val.strip():
|
||||||
return True
|
return 1
|
||||||
csum = fieldChecksum(val)
|
csum = fieldChecksum(val)
|
||||||
# find any matching csums and compare
|
# find any matching csums and compare
|
||||||
for flds in self.col.db.list(
|
for flds in self.col.db.list(
|
||||||
"select flds from notes where csum = ? and id != ? and mid = ?",
|
"select flds from notes where csum = ? and id != ? and mid = ?",
|
||||||
csum, self.id or 0, self.mid):
|
csum, self.id or 0, self.mid):
|
||||||
if splitFields(flds)[0] == self.fields[0]:
|
if splitFields(flds)[0] == self.fields[0]:
|
||||||
return True
|
return 2
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Flushing cloze notes
|
# Flushing cloze notes
|
||||||
|
|
Loading…
Reference in a new issue