From 35a09913853c2daa63a011e521d642acae2dbb71 Mon Sep 17 00:00:00 2001 From: William Ting Date: Mon, 16 Dec 2013 16:26:41 -0600 Subject: [PATCH] add increase directory weight --- bin/autojump.py | 20 ++++++++++---------- bin/data.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/autojump.py b/bin/autojump.py index 55363ed..037b83c 100755 --- a/bin/autojump.py +++ b/bin/autojump.py @@ -85,10 +85,10 @@ def parse_args(config): parser.add_argument( '-a', '--add', metavar='DIRECTORY', help='add path') - # parser.add_argument( - # '-i', '--increase', metavar='WEIGHT', nargs='?', type=int, - # const=20, default=False, - # help='manually increase path weight in database') + parser.add_argument( + '-i', '--increase', metavar='WEIGHT', nargs='?', type=int, + const=20, default=False, + help='increase current directory weight') # parser.add_argument( # '-d', '--decrease', metavar='WEIGHT', nargs='?', type=int, # const=15, default=False, @@ -115,11 +115,10 @@ def parse_args(config): add_path(config, args.add) sys.exit(0) - # if args.increase: - # print("%.2f:\t old directory weight" % db.get_weight(os.getcwd())) - # db.add(os.getcwd(), args.increase) - # print("%.2f:\t new directory weight" % db.get_weight(os.getcwd())) - # sys.exit(0) + if args.increase: + path, weight = add_path(config, os.getcwd(), args.increase) + print(encode_local("%.1f:\t%s" % (weight, path))) + sys.exit(0) # if args.decrease: # print("%.2f:\t old directory weight" % db.get_weight(os.getcwd())) @@ -154,7 +153,7 @@ def add_path(config, path, increment=10): """Add a new path or increment an existing one.""" path = decode(path).rstrip(os.sep) if path == os.path.expanduser('~'): - return + return path, 0 data = load(config) @@ -164,6 +163,7 @@ def add_path(config, path, increment=10): data[path] = increment save(config, data) + return path, data[path] def print_stats(config): diff --git a/bin/data.py b/bin/data.py index b85fd2f..73db67d 100644 --- a/bin/data.py +++ b/bin/data.py @@ -58,7 +58,7 @@ def migrate_osx_xdg_data(config): Older versions incorrectly used Linux XDG_DATA_HOME paths on OS X. This migrates autojump files from ~/.local/share/autojump to ~/Library/autojump """ - assert is_osx(), "Expecting OSX." + assert is_osx(), "This function should only be run on OS X." xdg_data_home = os.path.join(os.path.expanduser('~'), '.local', 'share') xdg_aj_home = os.path.join(xdg_data_home, 'autojump')