mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Set default encoding to UTF-8 when opening database file. Closes #162.
This commit is contained in:
parent
50e6054e13
commit
d0e0a990ce
19
bin/autojump
19
bin/autojump
@ -34,7 +34,7 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
VERSION = 'release-v21.1.0'
|
VERSION = 'release-v21.1.1'
|
||||||
MAX_KEYWEIGHT = 1000
|
MAX_KEYWEIGHT = 1000
|
||||||
MAX_STORED_PATHS = 1000
|
MAX_STORED_PATHS = 1000
|
||||||
COMPLETION_SEPARATOR = '__'
|
COMPLETION_SEPARATOR = '__'
|
||||||
@ -114,11 +114,18 @@ class Database:
|
|||||||
"""
|
"""
|
||||||
if os.path.exists(self.filename):
|
if os.path.exists(self.filename):
|
||||||
try:
|
try:
|
||||||
with open(self.filename, 'r') as f:
|
if sys.version > (2, 6):
|
||||||
for line in f.readlines():
|
with open(self.filename, 'r', encoding = 'utf-8') as f:
|
||||||
weight, path = line[:-1].split("\t", 1)
|
for line in f.readlines():
|
||||||
path = decode(path, 'utf-8')
|
weight, path = line[:-1].split("\t", 1)
|
||||||
self.data[path] = float(weight)
|
path = decode(path, 'utf-8')
|
||||||
|
self.data[path] = float(weight)
|
||||||
|
else:
|
||||||
|
with open(self.filename, 'r') as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
weight, path = line[:-1].split("\t", 1)
|
||||||
|
path = decode(path, 'utf-8')
|
||||||
|
self.data[path] = float(weight)
|
||||||
except (IOError, EOFError):
|
except (IOError, EOFError):
|
||||||
self.load_backup(error_recovery)
|
self.load_backup(error_recovery)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user