mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Log rule import times
This commit is contained in:
		| @@ -1,21 +1,23 @@ | ||||
| import sys | ||||
| from . import conf, logs | ||||
| from .utils import eager | ||||
| from imp import load_source | ||||
| from pathlib import Path | ||||
| from . import conf, types, logs | ||||
| from .utils import eager | ||||
| from thefuck.types import CorrectedCommand, Rule | ||||
| import sys | ||||
|  | ||||
|  | ||||
| def load_rule(rule, settings): | ||||
|     """Imports rule module and returns it.""" | ||||
|     name = rule.name[:-3] | ||||
|     rule_module = load_source(name, str(rule)) | ||||
|     priority = getattr(rule_module, 'priority', conf.DEFAULT_PRIORITY) | ||||
|     return types.Rule(name, rule_module.match, | ||||
|                       rule_module.get_new_command, | ||||
|                       getattr(rule_module, 'enabled_by_default', True), | ||||
|                       getattr(rule_module, 'side_effect', None), | ||||
|                       settings.priority.get(name, priority), | ||||
|                       getattr(rule_module, 'requires_output', True)) | ||||
|     with logs.debug_time(u'Importing rule: {};'.format(name), settings): | ||||
|         rule_module = load_source(name, str(rule)) | ||||
|         priority = getattr(rule_module, 'priority', conf.DEFAULT_PRIORITY) | ||||
|     return Rule(name, rule_module.match, | ||||
|                 rule_module.get_new_command, | ||||
|                 getattr(rule_module, 'enabled_by_default', True), | ||||
|                 getattr(rule_module, 'side_effect', None), | ||||
|                 settings.priority.get(name, priority), | ||||
|                 getattr(rule_module, 'requires_output', True)) | ||||
|  | ||||
|  | ||||
| def get_loaded_rules(rules, settings): | ||||
| @@ -59,11 +61,11 @@ def make_corrected_commands(command, rules, settings): | ||||
|     for rule in rules: | ||||
|         new_commands = rule.get_new_command(command, settings) | ||||
|         if not isinstance(new_commands, list): | ||||
|             new_commands = [new_commands] | ||||
|             new_commands = (new_commands,) | ||||
|         for n, new_command in enumerate(new_commands): | ||||
|             yield types.CorrectedCommand(script=new_command, | ||||
|                                          side_effect=rule.side_effect, | ||||
|                                          priority=(n + 1) * rule.priority) | ||||
|             yield CorrectedCommand(script=new_command, | ||||
|                                    side_effect=rule.side_effect, | ||||
|                                    priority=(n + 1) * rule.priority) | ||||
|  | ||||
|  | ||||
| def remove_duplicates(corrected_commands): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user