소스 검색

Set default encoding to UTF-8 when opening database file. Closes #162.

pull/163/head
William Ting 12 년 전
부모
커밋
d0e0a990ce
1개의 변경된 파일13개의 추가작업 그리고 6개의 파일을 삭제
  1. +13
    -6
      bin/autojump

+ 13
- 6
bin/autojump 파일 보기

@ -34,7 +34,7 @@ import re
import shutil
from tempfile import NamedTemporaryFile
VERSION = 'release-v21.1.0'
VERSION = 'release-v21.1.1'
MAX_KEYWEIGHT = 1000
MAX_STORED_PATHS = 1000
COMPLETION_SEPARATOR = '__'
@ -114,11 +114,18 @@ class Database:
"""
if os.path.exists(self.filename):
try:
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)
if sys.version > (2, 6):
with open(self.filename, 'r', encoding = 'utf-8') as f:
for line in f.readlines():
weight, path = line[:-1].split("\t", 1)
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):
self.load_backup(error_recovery)
else:

불러오는 중...
취소
저장