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

remove maintenance based on weights, remove AUTOJUMP_KEEP_ALL_ENTRIES

This commit is contained in:
William Ting 2013-05-14 19:43:43 -05:00
parent ba6b1e54ae
commit 776f109b3a
4 changed files with 7 additions and 69 deletions

View File

@ -203,15 +203,6 @@ ADDITIONAL CONFIGURATION
export AUTOJUMP_IGNORE_CASE=1
- Prevent Database Entries' Decay
Default behavior is to decay unused database entries slowly over
time. Eventually when database limits are hit and maintenance is
run, autojump will purge older less used entries. To prevent decay,
add the following variable in your \~/.bashrc:
export AUTOJUMP_KEEP_ALL_ENTRIES=1
- Prefer Symbolic Links
Default behavior is to evaluate symbolic links into full paths as to

View File

@ -83,18 +83,6 @@ class Database:
self.save()
def decay(self):
"""
Decay database entries.
"""
try:
items = self.data.iteritems()
except AttributeError:
items = self.data.items()
for path, _ in items:
self.data[path] *= 0.9
def get_weight(self, path):
"""
Return path weight.
@ -137,12 +125,12 @@ class Database:
def maintenance(self):
"""
Trims and decays database entries when exceeding settings.
If database has exceeded max_paths, remove bottom 10% entries.
"""
if sum(self.data.values()) > self.config['max_weight']:
self.decay()
if len(self.data) > self.config['max_paths']:
self.trim()
remove_cnt = int(0.1 * len(self.data))
for path in sorted(self.data, key=self.data.get)[:remove_cnt]:
del self.data[path]
self.save()
@ -198,27 +186,15 @@ class Database:
print("Error while creating backup autojump file. (%s)" %
ex, file=sys.stderr)
def trim(self, percent=0.1):
"""
If database has exceeded MAX_STORED_PATHS, removes bottom 10%.
"""
dirs = list(self.data.items())
dirs.sort(key=operator.itemgetter(1))
remove_cnt = int(percent * len(dirs))
for path, _ in dirs[:remove_cnt]:
del self.data[path]
def set_defaults():
config = {}
config['version'] = 'release-v21.6.3'
config['max_weight'] = 1000
config['version'] = 'release-v21.6.4'
config['max_paths'] = 1000
config['separator'] = '__'
config['home'] = os.path.expanduser('HOME')
config['ignore_case'] = False
config['keep_entries'] = False
config['keep_symlinks'] = False
config['debug'] = False
@ -237,10 +213,6 @@ def parse_env(config):
if config['data'] == config['home']:
config['db'] = config['data'] + '/.autojump.txt'
if 'AUTOJUMP_KEEP_ALL_ENTRIES' in os.environ and \
os.environ.get('AUTOJUMP_KEEP_ALL_ENTRIES') == '1':
config['keep_entries'] = True
if 'AUTOJUMP_IGNORE_CASE' in os.environ and \
os.environ.get('AUTOJUMP_IGNORE_CASE') == '1':
config['ignore_case'] = True
@ -517,7 +489,6 @@ def main():
else:
return 1
if not config['keep_entries']:
db.maintenance()
return 0

View File

@ -155,21 +155,6 @@ export\ AUTOJUMP_IGNORE_CASE=1
.fi
.RE
.IP \[bu] 2
Prevent Database Entries\[aq] Decay
.RS 2
.PP
Default behavior is to decay unused database entries slowly over time.
Eventually when database limits are hit and maintenance is run, autojump
will purge older less used entries.
To prevent decay, add the following variable in your ~/.bashrc:
.IP
.nf
\f[C]
export\ AUTOJUMP_KEEP_ALL_ENTRIES=1
\f[]
.fi
.RE
.IP \[bu] 2
Prefer Symbolic Links
.RS 2
.PP

View File

@ -73,15 +73,6 @@ ADDITIONAL CONFIGURATION
export AUTOJUMP_IGNORE_CASE=1
- Prevent Database Entries' Decay
Default behavior is to decay unused database entries slowly over
time. Eventually when database limits are hit and maintenance is
run, autojump will purge older less used entries. To prevent decay,
add the following variable in your \~/.bashrc:
export AUTOJUMP_KEEP_ALL_ENTRIES=1
- Prefer Symbolic Links
Default behavior is to evaluate symbolic links into full paths as to