1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

save the database in sorted form, for easier edition

This commit is contained in:
Joël Schaerer 2011-09-13 15:28:12 +02:00
parent 0ee020c72c
commit 92b80073fd

View File

@ -80,9 +80,9 @@ def save(path_dict, dic_file):
# Otherwise, fail quietly # Otherwise, fail quietly
if (not os.path.exists(dic_file)) or os.getuid() == os.stat(dic_file)[4]: if (not os.path.exists(dic_file)) or os.getuid() == os.stat(dic_file)[4]:
temp = NamedTemporaryFile(dir=CONFIG_DIR, delete=False) temp = NamedTemporaryFile(dir=CONFIG_DIR, delete=False)
for path in path_dict: for path,weight in sorted(path_dict.items(),key=itemgetter(1),reverse=True):
# the db is stored in utf-8 # the db is stored in utf-8
temp.write((unico("%s\t%s\n")%(path_dict[path],path)).encode("utf-8")) temp.write((unico("%s\t%s\n")%(weight,path)).encode("utf-8"))
temp.flush() temp.flush()
os.fsync(temp) os.fsync(temp)
temp.close() temp.close()