diff --git a/Makefile b/Makefile index 8900db3..7bb47de 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,4 @@ release: git archive --format=tar --prefix autojump_$(VERSION)/ $(TAGNAME) | gzip > autojump_$(VERSION).tar.gz test: - python tests/runtests.py + @tests/runtests.py diff --git a/bin/autojump b/bin/autojump index 406de3c..b591827 100755 --- a/bin/autojump +++ b/bin/autojump @@ -29,7 +29,7 @@ import shutil import sys from tempfile import NamedTemporaryFile -VERSION = 'release-v20-6' +VERSION = 'release-v20-7' MAX_KEYWEIGHT = 1000 MAX_STORED_PATHS = 1000 COMPLETION_SEPARATOR = '__' @@ -37,32 +37,27 @@ ARGS = None CONFIG_DIR = None DB_FILE = None - TESTING = False -KEEP_ALL_ENTRIES = False -IGNORE_CASE = False -def config(testing=False): - global TESTING, CONFIG_DIR, KEEP_ALL_ENTRIES, DB_FILE - TESTING = testing - - # load config from environmental variables - if 'AUTOJUMP_DATA_DIR' in os.environ: - CONFIG_DIR = os.environ.get('AUTOJUMP_DATA_DIR') - else: - xdg_data_dir = os.environ.get('XDG_DATA_HOME') or os.path.join(os.environ['HOME'], '.local', 'share') - CONFIG_DIR = os.path.join(xdg_data_dir, 'autojump') +# load config from environmental variables +if 'AUTOJUMP_DATA_DIR' in os.environ: + CONFIG_DIR = os.environ.get('AUTOJUMP_DATA_DIR') +else: + xdg_data_dir = os.environ.get('XDG_DATA_HOME') or os.path.join(os.environ['HOME'], '.local', 'share') + CONFIG_DIR = os.path.join(xdg_data_dir, 'autojump') - if 'AUTOJUMP_KEEP_ALL_ENTRIES' in os.environ and os.environ.get('AUTOJUMP_KEEP_ALL_ENTRIES') == '1': - KEEP_ALL_ENTRIES = True +KEEP_ALL_ENTRIES = False +if 'AUTOJUMP_KEEP_ALL_ENTRIES' in os.environ and os.environ.get('AUTOJUMP_KEEP_ALL_ENTRIES') == '1': + KEEP_ALL_ENTRIES = True - if 'AUTOJUMP_IGNORE_CASE' in os.environ and os.environ.get('AUTOJUMP_IGNORE_CASE') == '1': - ALWAYS_IGNORE_CASE = True +ALWAYS_IGNORE_CASE = False +if 'AUTOJUMP_IGNORE_CASE' in os.environ and os.environ.get('AUTOJUMP_IGNORE_CASE') == '1': + ALWAYS_IGNORE_CASE = True - if CONFIG_DIR == os.path.expanduser('~'): - DB_FILE = CONFIG_DIR + '/.autojump.txt' - else: - DB_FILE = CONFIG_DIR + '/autojump.txt' +if CONFIG_DIR == os.path.expanduser('~'): + DB_FILE = CONFIG_DIR + '/.autojump.txt' +else: + DB_FILE = CONFIG_DIR + '/autojump.txt' class Database: """ @@ -226,6 +221,8 @@ def options(): """ Parse command line options. """ + global ARGS + parser = argparse.ArgumentParser(description='Automatically jump to directory passed as an argument.', epilog="Please see autojump(1) man pages for full documentation.") parser.add_argument('directory', metavar='DIR', nargs='*', default='', @@ -403,10 +400,6 @@ def shell_utility(): Run this when autojump is called as a shell utility. """ if options(): return True - config() - - global ARGS, COMPLETION_SEPARATOR, DB_FILE, \ - ALWAYS_IGNORE_CASE, KEEP_ALL_ENTRIES db = Database(DB_FILE) # if no directories, add empty string diff --git a/tests/runtests.py b/tests/runtests.py index 10b7646..c7b3dca 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -13,7 +13,7 @@ import unittest class TestAutojump(unittest.TestCase): def setUp(self): - autojump.config(True) + autojump.TESTING = True self.fd, DB_FILE = tempfile.mkstemp() self.db = autojump.Database(DB_FILE) pass