1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-20 20:09:07 +00:00

#298 Use eager decorator when we don't need lazines

This commit is contained in:
nvbn 2015-07-29 16:11:23 +03:00
parent d6e80b7835
commit 8962cf2ec1

View File

@ -1,7 +1,8 @@
import sys
from imp import load_source
from pathlib import Path
from . import conf, types, logs
import sys
from .utils import eager
def load_rule(rule, settings):
@ -26,6 +27,7 @@ def get_loaded_rules(rules, settings):
yield loaded_rule
@eager
def get_rules(user_dir, settings):
"""Returns all enabled rules."""
bundled = Path(__file__).parent \
@ -35,6 +37,7 @@ def get_rules(user_dir, settings):
return get_loaded_rules(sorted(bundled) + sorted(user), settings)
@eager
def get_matched_rules(command, rules, settings):
"""Returns first matched rule for command."""
script_only = command.stdout is None and command.stderr is None
@ -64,11 +67,11 @@ def make_corrected_commands(command, rules, settings):
def get_corrected_commands(command, user_dir, settings):
rules = list(get_rules(user_dir, settings))
rules = get_rules(user_dir, settings)
logs.debug(
u'Loaded rules: {}'.format(', '.join(rule.name for rule in rules)),
settings)
matched = list(get_matched_rules(command, rules, settings))
matched = get_matched_rules(command, rules, settings)
logs.debug(
u'Matched rules: {}'.format(', '.join(rule.name for rule in matched)),
settings)