diff --git a/anki/exporting.py b/anki/exporting.py index 53de4490c..255f3c263 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -179,7 +179,12 @@ class AnkiExporter(Exporter): if dids and d['id'] not in dids: continue if not d['dyn'] and d['conf'] != 1: - dconfs[d['conf']] = True + if self.includeSched: + dconfs[d['conf']] = True + if not self.includeSched: + # scheduling not included, so reset deck settings to default + d = dict(d) + d['conf'] = 1 self.dst.decks.update(d) # copy used deck confs for dc in self.src.decks.allConf(): diff --git a/tests/test_exporting.py b/tests/test_exporting.py index 0c5062d64..ec79771e5 100644 --- a/tests/test_exporting.py +++ b/tests/test_exporting.py @@ -28,13 +28,33 @@ def setup1(): @nose.with_setup(setup1) def test_export_anki(): + # create a new deck with its own conf to test conf copying + did = deck.decks.id("test") + dobj = deck.decks.get(did) + confId = deck.decks.confId("newconf") + conf = deck.decks.getConf(confId) + conf['new']['perDay'] = 5 + deck.decks.save(conf) + deck.decks.setConf(dobj, confId) + # export e = AnkiExporter(deck) newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1]) os.unlink(newname) e.exportInto(newname) + # exporting should not have changed conf for original deck + conf = deck.decks.confForDid(did) + assert conf['id'] != 1 # connect to new deck d2 = aopen(newname) assert d2.cardCount() == 2 + # as scheduling was reset, should also revert decks to default conf + did = d2.decks.id("test", create=False) + assert did + conf2 = d2.decks.confForDid(did) + assert conf2['new']['perDay'] == 20 + dobj = d2.decks.get(did) + # conf should be 1 + assert dobj['conf'] == 1 # try again, limited to a deck newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1]) os.unlink(newname)