#364 Attach user_dir to settings

This commit is contained in:
nvbn
2015-09-07 18:59:10 +03:00
parent df4d2cc88d
commit f3525e9fe0
5 changed files with 17 additions and 9 deletions
+2
View File
@@ -109,6 +109,8 @@ def init_settings(user_dir):
"""Fills `settings` with values from `settings.py` and env."""
from .logs import exception
settings.user_dir = user_dir
try:
settings.update(_settings_from_file(user_dir))
except Exception:
+4 -4
View File
@@ -31,12 +31,12 @@ def get_loaded_rules(rules):
yield loaded_rule
def get_rules(user_dir):
def get_rules():
"""Returns all enabled rules."""
bundled = Path(__file__).parent \
.joinpath('rules') \
.glob('*.py')
user = user_dir.joinpath('rules').glob('*.py')
user = settings.user_dir.joinpath('rules').glob('*.py')
return sorted(get_loaded_rules(sorted(bundled) + sorted(user)),
key=lambda rule: rule.priority)
@@ -66,9 +66,9 @@ def make_corrected_commands(command, rule):
priority=(n + 1) * rule.priority)
def get_corrected_commands(command, user_dir):
def get_corrected_commands(command):
corrected_commands = (
corrected for rule in get_rules(user_dir)
corrected for rule in get_rules()
if is_rule_match(command, rule)
for corrected in make_corrected_commands(command, rule))
return SortedCorrectedCommandsSequence(corrected_commands)
+1 -1
View File
@@ -98,7 +98,7 @@ def fix_command():
logs.debug('Empty command, nothing to do')
return
corrected_commands = get_corrected_commands(command, user_dir)
corrected_commands = get_corrected_commands(command)
selected_command = select_command(corrected_commands)
if selected_command:
run_command(command, selected_command)