UPDATE_MODE

This commit is contained in:
Arthur Milchior 2020-01-30 16:48:37 -08:00
parent 957dc51fca
commit a2eea7a1bb

View File

@ -52,9 +52,10 @@ class ForeignCard:
# If the first field of the model is not in the map, the map is invalid. # If the first field of the model is not in the map, the map is invalid.
# The import mode is one of: # The import mode is one of:
# 0: update if first field matches existing note # UPDATE_MODE: update if first field matches existing note
# 1: ignore if first field matches existing note # 1: ignore if first field matches existing note
# 2: import even if first field matches existing note # 2: import even if first field matches existing note
UPDATE_MODE = 0
class NoteImporter(Importer): class NoteImporter(Importer):
@ -62,7 +63,7 @@ class NoteImporter(Importer):
needMapper = True needMapper = True
needDelimiter = False needDelimiter = False
allowHTML = False allowHTML = False
importMode = 0 importMode = UPDATE_MODE
mapping: Optional[List[str]] mapping: Optional[List[str]]
tagModified: Optional[str] tagModified: Optional[str]
@ -168,7 +169,7 @@ class NoteImporter(Importer):
if fld0 == sflds[0]: if fld0 == sflds[0]:
# duplicate # duplicate
found = True found = True
if self.importMode == 0: if self.importMode == UPDATE_MODE:
data = self.updateData(n, id, sflds) data = self.updateData(n, id, sflds)
if data: if data:
updates.append(data) updates.append(data)
@ -214,7 +215,7 @@ class NoteImporter(Importer):
ngettext("%d note updated", "%d notes updated", self.updateCount) ngettext("%d note updated", "%d notes updated", self.updateCount)
% self.updateCount % self.updateCount
) )
if self.importMode == 0: if self.importMode == UPDATE_MODE:
unchanged = dupeCount - self.updateCount unchanged = dupeCount - self.updateCount
elif self.importMode == 1: elif self.importMode == 1:
unchanged = dupeCount unchanged = dupeCount