mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
add decrease_path
This commit is contained in:
parent
35a0991385
commit
bde9ac1d9f
@ -89,10 +89,10 @@ def parse_args(config):
|
|||||||
'-i', '--increase', metavar='WEIGHT', nargs='?', type=int,
|
'-i', '--increase', metavar='WEIGHT', nargs='?', type=int,
|
||||||
const=20, default=False,
|
const=20, default=False,
|
||||||
help='increase current directory weight')
|
help='increase current directory weight')
|
||||||
# parser.add_argument(
|
parser.add_argument(
|
||||||
# '-d', '--decrease', metavar='WEIGHT', nargs='?', type=int,
|
'-d', '--decrease', metavar='WEIGHT', nargs='?', type=int,
|
||||||
# const=15, default=False,
|
const=15, default=False,
|
||||||
# help='manually decrease path weight in database')
|
help='decrease current directory weight')
|
||||||
# parser.add_argument(
|
# parser.add_argument(
|
||||||
# '-b', '--bash', action="store_true", default=False,
|
# '-b', '--bash', action="store_true", default=False,
|
||||||
# help='enclose directory quotes to prevent errors')
|
# help='enclose directory quotes to prevent errors')
|
||||||
@ -120,11 +120,10 @@ def parse_args(config):
|
|||||||
print(encode_local("%.1f:\t%s" % (weight, path)))
|
print(encode_local("%.1f:\t%s" % (weight, path)))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# if args.decrease:
|
if args.decrease:
|
||||||
# print("%.2f:\t old directory weight" % db.get_weight(os.getcwd()))
|
path, weight = decrease_path(config, os.getcwd(), args.decrease)
|
||||||
# db.decrease(os.getcwd(), args.decrease)
|
print(encode_local("%.1f:\t%s" % (weight, path)))
|
||||||
# print("%.2f:\t new directory weight" % db.get_weight(os.getcwd()))
|
sys.exit(0)
|
||||||
# sys.exit(0)
|
|
||||||
|
|
||||||
# if args.purge:
|
# if args.purge:
|
||||||
# removed = db.purge()
|
# removed = db.purge()
|
||||||
@ -166,6 +165,17 @@ def add_path(config, path, increment=10):
|
|||||||
return path, data[path]
|
return path, data[path]
|
||||||
|
|
||||||
|
|
||||||
|
def decrease_path(config, path, increment=15):
|
||||||
|
"""Decrease weight of existing path."""
|
||||||
|
path = decode(path).rstrip(os.sep)
|
||||||
|
data = load(config)
|
||||||
|
|
||||||
|
data[path] = max(0, data[path]-increment)
|
||||||
|
|
||||||
|
save(config, data)
|
||||||
|
return path, data[path]
|
||||||
|
|
||||||
|
|
||||||
def print_stats(config):
|
def print_stats(config):
|
||||||
data = load(config)
|
data = load(config)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user