report # of notes that are already in the collection

This commit is contained in:
Damien Elmes 2012-09-15 09:39:10 +09:00
parent c127f4b3c8
commit da639c00a5
2 changed files with 5 additions and 1 deletions

View file

@ -69,6 +69,7 @@ class Anki2Importer(Importer):
add = [] add = []
dirty = [] dirty = []
usn = self.dst.usn() usn = self.dst.usn()
dupes = 0
for note in self.src.db.execute( for note in self.src.db.execute(
"select * from notes"): "select * from notes"):
# turn the db result into a mutable list # turn the db result into a mutable list
@ -90,6 +91,7 @@ class Anki2Importer(Importer):
# note we have the added note # note we have the added note
self._notes[guid] = (note[0], note[3], note[2]) self._notes[guid] = (note[0], note[3], note[2])
else: else:
dupes += 1
pass pass
## update existing note - not yet tested; for post 2.0 ## update existing note - not yet tested; for post 2.0
# newer = note[3] > mod # newer = note[3] > mod
@ -99,6 +101,9 @@ class Anki2Importer(Importer):
# note[4] = usn # note[4] = usn
# add.append(note) # add.append(note)
# dirty.append(note[0]) # dirty.append(note[0])
if dupes:
self.log.append(_("Already in collection: %s.") % (ngettext(
"%d note", "%d notes", dupes) % dupes))
# add to col # add to col
self.dst.db.executemany( self.dst.db.executemany(
"insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)", "insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)",

View file

@ -151,7 +151,6 @@ class NoteImporter(Importer):
# apply scheduling updates # apply scheduling updates
self.updateCards() self.updateCards()
# make sure to update sflds, etc # make sure to update sflds, etc
part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new) part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new)
part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount
self.log.append("%s, %s." % (part1, part2)) self.log.append("%s, %s." % (part1, part2))