mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 05:07:10 -05:00
add warning when import fails to generate cards
This commit is contained in:
parent
eb7240d220
commit
cb17319e4e
1 changed files with 9 additions and 3 deletions
|
|
@ -112,6 +112,7 @@ class NoteImporter(Importer):
|
||||||
new = []
|
new = []
|
||||||
self._ids = []
|
self._ids = []
|
||||||
self._cards = []
|
self._cards = []
|
||||||
|
self._emptyNotes = False
|
||||||
for n in notes:
|
for n in notes:
|
||||||
fld0 = n.fields[fld0idx]
|
fld0 = n.fields[fld0idx]
|
||||||
csum = fieldChecksum(fld0)
|
csum = fieldChecksum(fld0)
|
||||||
|
|
@ -167,6 +168,10 @@ class NoteImporter(Importer):
|
||||||
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))
|
||||||
|
self.log.append(_("""\
|
||||||
|
One or more notes were not imported, because they didn't generate any cards. \
|
||||||
|
This can happen when you have empty fields or when you have not mapped the \
|
||||||
|
content in the text file to the correct fields."""))
|
||||||
self.total = len(self._ids)
|
self.total = len(self._ids)
|
||||||
|
|
||||||
def newData(self, n):
|
def newData(self, n):
|
||||||
|
|
@ -174,7 +179,6 @@ class NoteImporter(Importer):
|
||||||
self._nextID += 1
|
self._nextID += 1
|
||||||
self._ids.append(id)
|
self._ids.append(id)
|
||||||
if not self.processFields(n):
|
if not self.processFields(n):
|
||||||
print "no cards generated"
|
|
||||||
return
|
return
|
||||||
# note id for card updates later
|
# note id for card updates later
|
||||||
for ord, c in n.cards.items():
|
for ord, c in n.cards.items():
|
||||||
|
|
@ -193,7 +197,6 @@ class NoteImporter(Importer):
|
||||||
def updateData(self, n, id, sflds):
|
def updateData(self, n, id, sflds):
|
||||||
self._ids.append(id)
|
self._ids.append(id)
|
||||||
if not self.processFields(n, sflds):
|
if not self.processFields(n, sflds):
|
||||||
print "no cards generated"
|
|
||||||
return
|
return
|
||||||
if self._tagsMapped:
|
if self._tagsMapped:
|
||||||
self.col.tags.register(n.tags)
|
self.col.tags.register(n.tags)
|
||||||
|
|
@ -228,7 +231,10 @@ where id = ? and flds != ?""", rows)
|
||||||
sidx = self._fmap[f][0]
|
sidx = self._fmap[f][0]
|
||||||
fields[sidx] = note.fields[c]
|
fields[sidx] = note.fields[c]
|
||||||
note.fieldsStr = joinFields(fields)
|
note.fieldsStr = joinFields(fields)
|
||||||
return self.col.models.availOrds(self.model, note.fieldsStr)
|
ords = self.col.models.availOrds(self.model, note.fieldsStr)
|
||||||
|
if not ords:
|
||||||
|
self._emptyNotes = True
|
||||||
|
return ords
|
||||||
|
|
||||||
def updateCards(self):
|
def updateCards(self):
|
||||||
data = []
|
data = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue