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