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

Reorganize imports

This commit is contained in:
nvbn 2015-09-02 09:43:40 +03:00
parent fc35ee657e
commit b0195a8748
3 changed files with 15 additions and 16 deletions

View File

@ -1,8 +1,7 @@
from . import conf, types, logs
import sys
from imp import load_source
from pathlib import Path
from thefuck.types import CorrectedCommand, Rule
import sys
from . import conf, types, logs
def load_rule(rule, settings):
@ -11,12 +10,12 @@ def load_rule(rule, settings):
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))
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))
def get_loaded_rules(rules, settings):

View File

@ -1,9 +1,9 @@
""" This file provide some utility functions for Arch Linux specific rules."""
import thefuck.utils
import subprocess
from .. import utils
@thefuck.utils.memoize
@utils.memoize
def get_pkgfile(command):
""" Gets the packages that provide the given command using `pkgfile`.
@ -20,7 +20,7 @@ def get_pkgfile(command):
packages = subprocess.check_output(
['pkgfile', '-b', '-v', command],
universal_newlines=True, stderr=thefuck.utils.DEVNULL
universal_newlines=True, stderr=utils.DEVNULL
).splitlines()
return [package.split()[0] for package in packages]
@ -29,13 +29,13 @@ def get_pkgfile(command):
def archlinux_env():
if thefuck.utils.which('yaourt'):
if utils.which('yaourt'):
pacman = 'yaourt'
elif thefuck.utils.which('pacman'):
elif utils.which('pacman'):
pacman = 'sudo pacman'
else:
return False, None
enabled_by_default = thefuck.utils.which('pkgfile')
enabled_by_default = utils.which('pkgfile')
return enabled_by_default, pacman

View File

@ -1,5 +1,5 @@
import subprocess
from thefuck.utils import memoize, which
from ..utils import memoize, which
enabled_by_default = bool(which('brew'))