fix unicode issues with cram and open online

This commit is contained in:
Damien Elmes 2009-01-07 13:19:54 +09:00
parent b9c765e7b9
commit 4a268fcfc0

View file

@ -754,7 +754,7 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
self.ensureSyncParams() self.ensureSyncParams()
if not self.saveAndClose(hideWelcome=True): return if not self.saveAndClose(hideWelcome=True): return
# we need a disk-backed file for syncing # we need a disk-backed file for syncing
dir = tempfile.mkdtemp() dir = unicode(tempfile.mkdtemp(), sys.getfilesystemencoding())
path = os.path.join(dir, u"untitled.anki") path = os.path.join(dir, u"untitled.anki")
self.onNew(path=path) self.onNew(path=path)
# ensure all changes come to us # ensure all changes come to us
@ -1321,13 +1321,13 @@ day = :d""", d=yesterday)
s = unicode(s) s = unicode(s)
self.deck.save() self.deck.save()
# open tmp deck # open tmp deck
import tempfile
ndir = tempfile.mkdtemp(prefix="anki-cram") ndir = tempfile.mkdtemp(prefix="anki-cram")
path = os.path.join(ndir, "cram.anki") path = os.path.join(ndir, "cram.anki")
from anki.exporting import AnkiExporter from anki.exporting import AnkiExporter
e = AnkiExporter(self.deck) e = AnkiExporter(self.deck)
if s: if s:
e.limitTags = parseTags(s) e.limitTags = parseTags(s)
path = unicode(path, sys.getfilesystemencoding())
e.exportInto(path) e.exportInto(path)
if not e.exportedCards: if not e.exportedCards:
ui.utils.showInfo(_("No cards matched the provided tags.")) ui.utils.showInfo(_("No cards matched the provided tags."))