From 96337615a52b1088fc51b92d60d41faef41fe408 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 17 Jan 2009 16:29:26 +0900 Subject: [PATCH] identify all temp files as anki, remove kanji occur, tools>actions again --- ankiqt/ui/facteditor.py | 4 ++-- ankiqt/ui/main.py | 20 ++------------------ ankiqt/ui/update.py | 2 +- designer/cardlist.ui | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index 7e4d2d3a8..b1d302daf 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -643,7 +643,7 @@ class FactEdit(QTextEdit): return if source.hasImage(): im = QImage(source.imageData()) - (fd, name) = tempfile.mkstemp(suffix=".jpg") + (fd, name) = tempfile.mkstemp(prefix="anki", suffix=".jpg") uname = unicode(name, sys.getfilesystemencoding()) im.save(uname, None, 95) self.parent._addPicture(uname, widget=self) @@ -665,7 +665,7 @@ class FactEdit(QTextEdit): def _retrieveURL(self, url, ext): filecontents = urllib2.urlopen(url).read() - (fd, name) = tempfile.mkstemp(suffix=".%s" % ext.encode("ascii")) + (fd, name) = tempfile.mkstemp(prefix="anki", suffix=".%s" % ext.encode("ascii")) file = os.fdopen(fd, "wb") file.write(filecontents) file.flush() diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index c18522f5f..0da1deab7 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -777,7 +777,7 @@ To upgrade an old deck, download Anki 0.9.8.7.""")) self.ensureSyncParams() if not self.saveAndClose(hideWelcome=True): return # we need a disk-backed file for syncing - dir = unicode(tempfile.mkdtemp(), sys.getfilesystemencoding()) + dir = unicode(tempfile.mkdtemp(prefix="anki"), sys.getfilesystemencoding()) path = os.path.join(dir, u"untitled.anki") self.onNew(path=path) # ensure all changes come to us @@ -1237,22 +1237,6 @@ day = :d""", d=yesterday) else: ui.utils.showInfo(_("Please install python-matplotlib to access graphs.")) - def onKanjiOccur(self): - self.setStatus(_("Generating report (may take time)...")) - self.app.processEvents() - import tempfile - (fd, name) = tempfile.mkstemp(suffix=".html") - f = os.fdopen(fd, 'w') - ko = anki.stats.KanjiOccurStats(self.deck) - ko.reportFile(f) - f.close() - if sys.platform == "win32": - url = "file:///" - else: - url = "file://" - url += os.path.abspath(name) - QDesktopServices.openUrl(QUrl(url)) - # Marking, suspending and undoing ########################################################################## @@ -1361,7 +1345,7 @@ day = :d""", d=yesterday) s = unicode(s) self.deck.save() # open tmp deck - ndir = tempfile.mkdtemp(prefix="anki-cram") + ndir = tempfile.mkdtemp(prefix="anki") path = os.path.join(ndir, "cram.anki") from anki.exporting import AnkiExporter e = AnkiExporter(self.deck) diff --git a/ankiqt/ui/update.py b/ankiqt/ui/update.py index 2018240e0..6a73c1e3d 100644 --- a/ankiqt/ui/update.py +++ b/ankiqt/ui/update.py @@ -77,7 +77,7 @@ class Updater(QThread): self.emit(SIGNAL("statusChanged"), msg, timeout) def run(self): - dir = tempfile.mkdtemp(prefix="anki-update") + dir = tempfile.mkdtemp(prefix="anki") os.chdir(dir) filename = os.path.abspath(self.filename) try: diff --git a/designer/cardlist.ui b/designer/cardlist.ui index 10e9a5836..88d045c01 100644 --- a/designer/cardlist.ui +++ b/designer/cardlist.ui @@ -186,7 +186,7 @@ - &Tools + &Actions