remove dupeOnSchemaChange
no longer required now that anki 1.x importing dropped
This commit is contained in:
parent
ff2e7b9e81
commit
08e0174f2e
@ -19,7 +19,6 @@ class Anki2Importer(Importer):
|
||||
needMapper = False
|
||||
deckPrefix = None
|
||||
allowUpdate = True
|
||||
dupeOnSchemaChange = False
|
||||
|
||||
def run(self, media=None):
|
||||
self._prepareFiles()
|
||||
@ -65,9 +64,8 @@ class Anki2Importer(Importer):
|
||||
# we may need to rewrite the guid if the model schemas don't match,
|
||||
# so we need to keep track of the changes for the card import stage
|
||||
self._changedGuids = {}
|
||||
# apart from upgrading from anki1 decks, we ignore updates to changed
|
||||
# schemas. we need to note the ignored guids, so we avoid importing
|
||||
# invalid cards
|
||||
# we ignore updates to changed schemas. we need to note the ignored
|
||||
# guids, so we avoid importing invalid cards
|
||||
self._ignoredGuids = {}
|
||||
# iterate over source collection
|
||||
add = []
|
||||
@ -149,20 +147,9 @@ class Anki2Importer(Importer):
|
||||
note[MID] = dstMid
|
||||
if origGuid not in self._notes:
|
||||
return True
|
||||
# as the schemas differ and we already have a note with a different
|
||||
# note type, this note needs a new guid
|
||||
if not self.dupeOnSchemaChange:
|
||||
# schema changed; don't import
|
||||
self._ignoredGuids[origGuid] = True
|
||||
return False
|
||||
while True:
|
||||
note[GUID] = incGuid(note[GUID])
|
||||
self._changedGuids[origGuid] = note[GUID]
|
||||
# if we don't have an existing guid, we can add
|
||||
if note[GUID] not in self._notes:
|
||||
return True
|
||||
# if the existing guid shares the same mid, we can reuse
|
||||
if dstMid == self._notes[note[GUID]][MID]:
|
||||
return False
|
||||
|
||||
# Models
|
||||
######################################################################
|
||||
|
@ -75,38 +75,6 @@ def test_apkg():
|
||||
imp.run()
|
||||
assert len(os.listdir(tmp.media.dir())) == 2
|
||||
|
||||
def test_anki2_diffmodels():
|
||||
# create a new empty deck
|
||||
dst = getEmptyCol()
|
||||
# import the 1 card version of the model
|
||||
tmp = getUpgradeDeckPath("diffmodels2-1.apkg")
|
||||
imp = AnkiPackageImporter(dst, tmp)
|
||||
imp.dupeOnSchemaChange = True
|
||||
imp.run()
|
||||
before = dst.noteCount()
|
||||
# repeating the process should do nothing
|
||||
imp = AnkiPackageImporter(dst, tmp)
|
||||
imp.dupeOnSchemaChange = True
|
||||
imp.run()
|
||||
assert before == dst.noteCount()
|
||||
# then the 2 card version
|
||||
tmp = getUpgradeDeckPath("diffmodels2-2.apkg")
|
||||
imp = AnkiPackageImporter(dst, tmp)
|
||||
imp.dupeOnSchemaChange = True
|
||||
imp.run()
|
||||
after = dst.noteCount()
|
||||
# as the model schemas differ, should have been imported as new model
|
||||
assert after == before + 1
|
||||
# and the new model should have both cards
|
||||
assert dst.cardCount() == 3
|
||||
# repeating the process should do nothing
|
||||
imp = AnkiPackageImporter(dst, tmp)
|
||||
imp.dupeOnSchemaChange = True
|
||||
imp.run()
|
||||
after = dst.noteCount()
|
||||
assert after == before + 1
|
||||
assert dst.cardCount() == 3
|
||||
|
||||
def test_anki2_diffmodel_templates():
|
||||
# different from the above as this one tests only the template text being
|
||||
# changed, not the number of cards/fields
|
||||
|
Loading…
Reference in New Issue
Block a user