mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Merge branch 'master' of https://github.com/dae/anki
This commit is contained in:
commit
bf37b7de7a
8 changed files with 28 additions and 13 deletions
|
@ -30,6 +30,6 @@ if arch[1] == "ELF":
|
|||
sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % (
|
||||
sys.version_info[1], arch[0][0:2])))
|
||||
|
||||
version="2.0.25" # build scripts grep this line, so preserve formatting
|
||||
version="2.0.26" # build scripts grep this line, so preserve formatting
|
||||
from anki.storage import Collection
|
||||
__all__ = ["Collection"]
|
||||
|
|
|
@ -4,7 +4,7 @@ from anki.hooks import runFilter
|
|||
from anki.template import furigana; furigana.install()
|
||||
from anki.template import hint; hint.install()
|
||||
|
||||
clozeReg = r"\{\{c%s::(.*?)(::(.*?))?\}\}"
|
||||
clozeReg = r"(?s)\{\{c%s::(.*?)(::(.*?))?\}\}"
|
||||
|
||||
modifiers = {}
|
||||
def modifier(symbol):
|
||||
|
|
|
@ -383,7 +383,9 @@ the manual for information on how to restore from an automatic backup."))
|
|||
if cleanup:
|
||||
cleanup(state)
|
||||
self.state = state
|
||||
runHook('beforeStateChange', state, oldState, *args)
|
||||
getattr(self, "_"+state+"State")(oldState, *args)
|
||||
runHook('afterStateChange', state, oldState, *args)
|
||||
|
||||
def _deckBrowserState(self, oldState):
|
||||
self.deckBrowser.show()
|
||||
|
|
|
@ -96,8 +96,7 @@ Your pysqlite2 is too old. Anki will appear frozen during long operations."""
|
|||
self._win.setCancelButton(None)
|
||||
self._win.setAutoClose(False)
|
||||
self._win.setAutoReset(False)
|
||||
if not isMac:
|
||||
self._win.setWindowModality(Qt.ApplicationModal)
|
||||
self._win.setWindowModality(Qt.ApplicationModal)
|
||||
# we need to manually manage minimum time to show, as qt gets confused
|
||||
# by the db handler
|
||||
self._win.setMinimumDuration(100000)
|
||||
|
|
|
@ -15,6 +15,7 @@ def assertException(exception, func):
|
|||
def getEmptyDeck():
|
||||
if len(getEmptyDeck.master) == 0:
|
||||
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
||||
os.close(fd)
|
||||
os.unlink(nam)
|
||||
col = aopen(nam)
|
||||
col.db.close()
|
||||
|
@ -28,6 +29,7 @@ getEmptyDeck.master = ""
|
|||
# Fallback for when the DB needs options passed in.
|
||||
def getEmptyDeckWith(**kwargs):
|
||||
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
|
||||
os.close(fd)
|
||||
os.unlink(nam)
|
||||
return aopen(nam, **kwargs)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import os, tempfile
|
||||
from tests.shared import assertException, getEmptyDeck
|
||||
from anki.stdmodels import addBasicModel
|
||||
|
||||
|
@ -11,8 +11,9 @@ newMod = None
|
|||
|
||||
def test_create():
|
||||
global newPath, newMod
|
||||
path = "/tmp/test_attachNew.anki2"
|
||||
(fd, path) = tempfile.mkstemp(suffix=".anki2", prefix="test_attachNew")
|
||||
try:
|
||||
os.close(fd)
|
||||
os.unlink(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
|
|
@ -36,7 +36,9 @@ def test_export_anki():
|
|||
deck.decks.setConf(dobj, confId)
|
||||
# export
|
||||
e = AnkiExporter(deck)
|
||||
newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1])
|
||||
fd, newname = tempfile.mkstemp(prefix="ankitest", suffix=".anki2")
|
||||
newname = unicode(newname)
|
||||
os.close(fd)
|
||||
os.unlink(newname)
|
||||
e.exportInto(newname)
|
||||
# exporting should not have changed conf for original deck
|
||||
|
@ -54,7 +56,9 @@ def test_export_anki():
|
|||
# conf should be 1
|
||||
assert dobj['conf'] == 1
|
||||
# try again, limited to a deck
|
||||
newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1])
|
||||
fd, newname = tempfile.mkstemp(prefix="ankitest", suffix=".anki2")
|
||||
newname = unicode(newname)
|
||||
os.close(fd)
|
||||
os.unlink(newname)
|
||||
e.did = 1
|
||||
e.exportInto(newname)
|
||||
|
@ -69,7 +73,9 @@ def test_export_ankipkg():
|
|||
n['Front'] = u'[sound:今日.mp3]'
|
||||
deck.addNote(n)
|
||||
e = AnkiPackageExporter(deck)
|
||||
newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".apkg")[1])
|
||||
fd, newname = tempfile.mkstemp(prefix="ankitest", suffix=".apkg")
|
||||
newname = unicode(newname)
|
||||
os.close(fd)
|
||||
os.unlink(newname)
|
||||
e.exportInto(newname)
|
||||
|
||||
|
@ -92,7 +98,9 @@ def test_export_anki_due():
|
|||
# export
|
||||
e = AnkiExporter(deck)
|
||||
e.includeSched = True
|
||||
newname = unicode(tempfile.mkstemp(prefix="ankitest", suffix=".anki2")[1])
|
||||
fd, newname = tempfile.mkstemp(prefix="ankitest", suffix=".anki2")
|
||||
newname = unicode(newname)
|
||||
os.close(fd)
|
||||
os.unlink(newname)
|
||||
e.exportInto(newname)
|
||||
# importing into a new deck, the due date should be equivalent
|
||||
|
@ -115,7 +123,9 @@ def test_export_anki_due():
|
|||
@nose.with_setup(setup1)
|
||||
def test_export_textnote():
|
||||
e = TextNoteExporter(deck)
|
||||
f = unicode(tempfile.mkstemp(prefix="ankitest")[1])
|
||||
fd, f = tempfile.mkstemp(prefix="ankitest")
|
||||
f = unicode(f)
|
||||
os.close(fd)
|
||||
os.unlink(f)
|
||||
e.exportInto(f)
|
||||
e.includeTags = True
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# coding: utf-8
|
||||
|
||||
import datetime, shutil
|
||||
import datetime, shutil, tempfile
|
||||
from anki import Collection
|
||||
from anki.consts import *
|
||||
from shared import getUpgradeDeckPath, testDir
|
||||
|
@ -63,8 +63,9 @@ def test_invalid_ords():
|
|||
assert deck.db.scalar("select count() from cards where ord = 1") == 1
|
||||
|
||||
def test_upgrade2():
|
||||
p = "/tmp/alpha-upgrade.anki2"
|
||||
fd, p = tempfile.mkstemp(suffix=".anki2", prefix="alpha-upgrade")
|
||||
if os.path.exists(p):
|
||||
os.close(fd)
|
||||
os.unlink(p)
|
||||
shutil.copy2(os.path.join(testDir, "support/anki2-alpha.anki2"), p)
|
||||
col = Collection(p)
|
||||
|
|
Loading…
Reference in a new issue