Move all app/os specific utils to specific package

This commit is contained in:
nvbn
2015-08-25 14:09:47 +03:00
parent 2e002f666b
commit b21c9ebb43
39 changed files with 214 additions and 182 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
import os
from difflib import get_close_matches
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
from thefuck.rules import cd_mkdir
__author__ = "mmussomele"
+1 -1
View File
@@ -1,6 +1,6 @@
import re
from thefuck import shells
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+1 -1
View File
@@ -1,5 +1,5 @@
import re
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+2 -1
View File
@@ -1,7 +1,8 @@
from itertools import dropwhile, takewhile, islice
import re
import subprocess
from thefuck.utils import sudo_support, replace_command
from thefuck.utils import replace_command
from thefuck.specific.sudo import sudo_support
@sudo_support
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
import re
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+3 -2
View File
@@ -1,14 +1,15 @@
import re
from thefuck import utils, shells
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('did not match any file(s) known to git.' in command.stderr
and "Did you forget to 'git add'?" in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
missing_file = re.findall(
r"error: pathspec '([^']*)' "
+3 -2
View File
@@ -1,13 +1,14 @@
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('branch -d' in command.script
and 'If you are sure you want to delete it' in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
return replace_argument(command.script, '-d', '-D')
+3 -2
View File
@@ -1,12 +1,13 @@
from thefuck import utils, shells
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
# catches "git branch list" in place of "git branch"
return command.script.split()[1:] == 'branch list'.split()
@utils.git_support
@git_support
def get_new_command(command, settings):
return shells.and_('git branch --delete list', 'git branch')
+3 -2
View File
@@ -2,9 +2,10 @@ import re
import subprocess
from thefuck import shells, utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('did not match any file(s) known to git.' in command.stderr
and "Did you forget to 'git add'?" not in command.stderr)
@@ -23,7 +24,7 @@ def get_branches():
yield line.strip()
@utils.git_support
@git_support
def get_new_command(command, settings):
missing_file = re.findall(
r"error: pathspec '([^']*)' "
+3 -2
View File
@@ -1,13 +1,14 @@
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('diff' in command.script and
'--staged' not in command.script)
@utils.git_support
@git_support
def get_new_command(command, settings):
return replace_argument(command.script, 'diff', 'diff --staged')
+3 -2
View File
@@ -1,8 +1,9 @@
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return (command.script.split()[1] == 'stash'
and 'usage:' in command.stderr)
@@ -19,7 +20,7 @@ stash_commands = (
'show')
@utils.git_support
@git_support
def get_new_command(command, settings):
stash_cmd = command.script.split()[2]
fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False)
+2 -2
View File
@@ -1,6 +1,6 @@
import re
from thefuck.utils import (git_support,
get_all_matched_commands, replace_command)
from thefuck.utils import get_all_matched_commands, replace_command
from thefuck.specific.git import git_support
@git_support
+3 -2
View File
@@ -1,13 +1,14 @@
from thefuck import shells, utils
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('pull' in command.script
and 'set-upstream' in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
line = command.stderr.split('\n')[-3].strip()
branch = line.split(' ')[-1]
+3 -2
View File
@@ -1,13 +1,14 @@
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('fatal: Not a git repository' in command.stderr
and "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)." in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
return replace_argument(command.script, 'pull', 'clone')
+3 -2
View File
@@ -1,12 +1,13 @@
from thefuck import utils
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('push' in command.script
and 'set-upstream' in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
return command.stderr.split('\n')[-3].strip()
+3 -2
View File
@@ -1,8 +1,9 @@
from thefuck import utils
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('push' in command.script
and '! [rejected]' in command.stderr
@@ -10,7 +11,7 @@ def match(command, settings):
and 'Updates were rejected because the tip of your current branch is behind' in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
return replace_argument(command.script, 'push', 'push --force')
+3 -2
View File
@@ -1,8 +1,9 @@
from thefuck import utils, shells
from thefuck.utils import replace_argument
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
return ('push' in command.script
and '! [rejected]' in command.stderr
@@ -10,7 +11,7 @@ def match(command, settings):
and 'Updates were rejected because the tip of your current branch is behind' in command.stderr)
@utils.git_support
@git_support
def get_new_command(command, settings):
return shells.and_(replace_argument(command.script, 'push', 'pull'),
command.script)
+3 -2
View File
@@ -1,14 +1,15 @@
from thefuck import shells, utils
from thefuck.specific.git import git_support
@utils.git_support
@git_support
def match(command, settings):
# catches "Please commit or stash them" and "Please, commit your changes or
# stash them before you can switch branches."
return 'or stash them' in command.stderr
@utils.git_support
@git_support
def get_new_command(command, settings):
formatme = shells.and_('git stash', '{}')
return formatme.format(command.script)
+1 -1
View File
@@ -1,5 +1,5 @@
import os
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+2 -2
View File
@@ -1,6 +1,6 @@
import re
from thefuck.utils import sudo_support,\
replace_command, get_all_matched_commands
from thefuck.utils import replace_command, get_all_matched_commands
from thefuck.specific.sudo import sudo_support
@sudo_support
+1 -1
View File
@@ -1,5 +1,5 @@
import re
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+2 -1
View File
@@ -1,5 +1,6 @@
from difflib import get_close_matches
from thefuck.utils import sudo_support, get_all_executables
from thefuck.utils import get_all_executables
from thefuck.specific.sudo import sudo_support
@sudo_support
+1 -1
View File
@@ -1,4 +1,4 @@
from thefuck.utils import get_pkgfile, archlinux_env
from thefuck.specific.archlinux import get_pkgfile, archlinux_env
from thefuck import shells
+2 -1
View File
@@ -6,7 +6,8 @@ should be:
yaourt -S llvm
"""
from thefuck.utils import replace_command, get_pkgfile, archlinux_env
from thefuck.utils import replace_command
from thefuck.specific.archlinux import get_pkgfile, archlinux_env
def match(command, settings):
+1 -1
View File
@@ -1,4 +1,4 @@
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
# add 'python' suffix to the command if
# 1) The script does not have execute permission or
# 2) is interpreted as shell script
+1 -1
View File
@@ -1,5 +1,5 @@
import re
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support
+1 -2
View File
@@ -1,5 +1,4 @@
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
enabled_by_default = False
+1 -1
View File
@@ -1,7 +1,7 @@
"""
The confusion in systemctl's param order is massive.
"""
from thefuck.utils import sudo_support
from thefuck.specific.sudo import sudo_support
@sudo_support