From 337e16391c1edbb587c628693936c0665a95c399 Mon Sep 17 00:00:00 2001 From: Tom Parker Date: Wed, 29 Apr 2009 19:04:22 +0800 Subject: [PATCH] jumpapplet: load_path breaks without an earlier config file When starting jumpapplet without an earlier config file, it raises an UnboundLocalError tparker@shostakovich:[~/data/src/autojump] ./jumpapplet loading settings no config file Traceback (most recent call last): File "./jumpapplet", line 93, in popup paths=load_paths(maxpath=defaults["maxpath"]) File "./jumpapplet", line 54, in load_paths path_dict=path_dict.items() UnboundLocalError: local variable 'path_dict' referenced before assignment This patch fixes that Signed-off-by: Pierre Gueth --- jumpapplet | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jumpapplet b/jumpapplet index ef616f7..197ee55 100755 --- a/jumpapplet +++ b/jumpapplet @@ -64,13 +64,12 @@ def load_paths(filename="~/.autojump_py",maxpath=10): aj_file=open(dic_file) path_dict=cPickle.load(aj_file) aj_file.close() - except IOError: - pass + path_dict=path_dict.items() + path_dict.sort(key=lambda x: x[1],reverse=True) - path_dict=path_dict.items() - path_dict.sort(key=lambda x: x[1],reverse=True) - - return [path for path,score in path_dict[:maxpath]] + return [path for path,score in path_dict[:maxpath]] + except IOError: + return [] def load_settings_file(filename="~/.jumpapplet_py"): print "loading settings"