mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
make sure we feed sqlite utf8, and use unicode for tmp filenames
This commit is contained in:
parent
9d153313e5
commit
5ddc4c639e
2 changed files with 4 additions and 3 deletions
|
@ -12,6 +12,8 @@ from anki.hooks import runHook
|
||||||
|
|
||||||
class DB(object):
|
class DB(object):
|
||||||
def __init__(self, path, text=None, timeout=0):
|
def __init__(self, path, text=None, timeout=0):
|
||||||
|
if isinstance(path, unicode):
|
||||||
|
path = path.encode("utf-8")
|
||||||
self._db = sqlite.connect(path, timeout=timeout)
|
self._db = sqlite.connect(path, timeout=timeout)
|
||||||
if text:
|
if text:
|
||||||
self._db.text_factory = text
|
self._db.text_factory = text
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import re, os, random, time, types, math, htmlentitydefs, subprocess, \
|
import re, os, random, time, types, math, htmlentitydefs, subprocess, \
|
||||||
tempfile, shutil, string, httplib2
|
tempfile, shutil, string, httplib2, sys, locale
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from anki.lang import _, ngettext
|
from anki.lang import _, ngettext
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
import locale, sys
|
|
||||||
|
|
||||||
if sys.version_info[1] < 5:
|
if sys.version_info[1] < 5:
|
||||||
def format_string(a, b):
|
def format_string(a, b):
|
||||||
|
@ -254,7 +253,7 @@ def tmpdir():
|
||||||
def tmpfile(prefix="", suffix=""):
|
def tmpfile(prefix="", suffix=""):
|
||||||
(fd, name) = tempfile.mkstemp(dir=tmpdir(), prefix=prefix, suffix=suffix)
|
(fd, name) = tempfile.mkstemp(dir=tmpdir(), prefix=prefix, suffix=suffix)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
return name
|
return unicode(name, sys.getfilesystemencoding())
|
||||||
|
|
||||||
def namedtmp(name, rm=True):
|
def namedtmp(name, rm=True):
|
||||||
"Return tmpdir+name. Deletes any existing file."
|
"Return tmpdir+name. Deletes any existing file."
|
||||||
|
|
Loading…
Reference in a new issue