Пример #1
0
def get_new_command(command):
    for idx, arg in enumerate(command.script_parts[1:]):
        # allowed params to ADB are a/d/e/s/H/P/L where s, H, P and L take additional args
        # for example 'adb -s 111 logcat' or 'adb -e logcat'
        if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-H', '-P', '-L'):
            adb_cmd = get_closest(arg, _ADB_COMMANDS)
            return replace_argument(command.script, arg, adb_cmd)
Пример #2
0
def match(command):
    is_proper_command = "brew" in command.script and "Unknown command" in command.stderr

    if is_proper_command:
        broken_cmd = re.findall(r"Error: Unknown command: ([a-z]+)", command.stderr)[0]
        return bool(get_closest(broken_cmd, _brew_commands()))
    return False
Пример #3
0
def match(command):
    is_proper_command = ('brew' in command.script and
                         'Unknown command' in command.stderr)

    if is_proper_command:
        broken_cmd = re.findall(r'Error: Unknown command: ([a-z]+)',
                                command.stderr)[0]
        return bool(get_closest(broken_cmd, _brew_commands()))
    return False
Пример #4
0
def get_new_command(command, settings):
    cmd = re.match(r"ambiguous command: (.*), could be: (.*)", command.stderr)

    old_cmd = cmd.group(1)
    suggestions = [cmd.strip() for cmd in cmd.group(2).split(",")]

    new_cmd = get_closest(old_cmd, suggestions)

    return replace_argument(command.script, old_cmd, new_cmd)
Пример #5
0
def get_new_command(command, settings):
    stash_cmd = command.script.split()[2]
    fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False)

    if fixed is not None:
        return replace_argument(command.script, stash_cmd, fixed)
    else:
        cmd = command.script.split()
        cmd.insert(2, 'save')
        return ' '.join(cmd)
Пример #6
0
def match(command, settings):
    is_proper_command = ('brew' in command.script and
                         'Unknown command' in command.stderr)

    has_possible_commands = False
    if is_proper_command:
        broken_cmd = re.findall(r'Error: Unknown command: ([a-z]+)',
                                command.stderr)[0]
        has_possible_commands = bool(get_closest(broken_cmd, brew_commands))

    return has_possible_commands
Пример #7
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.stderr)[0]
    closest_branch = utils.get_closest(missing_file, get_branches(),
                                       fallback_to_first=False)
    if closest_branch:
        return replace_argument(command.script, missing_file, closest_branch)
    else:
        return shells.and_('git branch {}', '{}').format(
            missing_file, command.script)
Пример #8
0
def get_new_command(command):
    not_found_commands = _get_between(
        command.stderr, 'Warning: Command(s) not found:', 'Available commands:')
    possible_commands = _get_between(
        command.stdout, 'Available commands:')

    script = command.script
    for not_found in not_found_commands:
        fix = get_closest(not_found, possible_commands)
        script = script.replace(' {}'.format(not_found),
                                ' {}'.format(fix))

    return script
Пример #9
0
def get_new_command(command):
    old_command = command.script_parts[0]

    # One from history:
    already_used = get_closest(
        old_command, _get_used_executables(command),
        fallback_to_first=False)
    if already_used:
        new_cmds = [already_used]
    else:
        new_cmds = []

    # Other from all executables:
    new_cmds += [cmd for cmd in get_close_matches(old_command,
                                                  get_all_executables())
                 if cmd not in new_cmds]

    return [' '.join([new_command] + command.script_parts[1:])
            for new_command in new_cmds]
Пример #10
0
def get_new_command(command):
    if len(command.script_parts) <= 1:
        return []

    badrule = command.stderr.split("`")[1].split("'")[0]

    from subprocess import call, Popen, PIPE

    proc = Popen(["make", "-qp"], stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = proc.communicate()

    import re
    matcher = re.compile(r'^[a-zA-Z0-9][^$#/\t=]*:([^=$])*$', re.MULTILINE)
    possibilities = []

    for s in stdout.split("\n"):
        res = matcher.match(s)
        if res:
            possibilities.append(res.group(0).split(":")[0])

    return [" ".join(command.script_parts).replace(badrule, get_closest(badrule, possibilities, 5))]
Пример #11
0
def get_new_command(command, settings):
    script = command.script.split(' ')
    possibilities = extract_possibilities(command)
    script[1] = get_closest(script[1], possibilities)
    return ' '.join(script)
Пример #12
0
def get_new_command(command):
    return get_closest(command.script,
                       _history_of_exists_without_current(command))
Пример #13
0
def get_new_command(command, settings):
    wrong_command = re.findall(
        r"docker: '(\w+)' is not a docker command.", command.stderr)[0]
    fixed_command = get_closest(wrong_command, get_docker_commands())
    return replace_argument(command.script, wrong_command, fixed_command)
Пример #14
0
 def test_when_can_match(self):
     assert 'branch' == get_closest('brnch', ['branch', 'status'])
Пример #15
0
def _get_similar_formula(formula_name):
    return get_closest(formula_name, _get_formulas(), 1, 0.85)
Пример #16
0
def get_new_command(command, settings):
    return get_closest(command.script,
                       _history_of_exists_without_current(command))
Пример #17
0
def get_new_command(command):
    npm_commands = _get_available_commands(command.output)
    wrong_command = _get_wrong_command(command.script_parts)
    fixed = get_closest(wrong_command, npm_commands)
    return replace_argument(command.script, wrong_command, fixed)
Пример #18
0
 def test_when_cant_match(self):
     assert 'status' == get_closest('st', ['status', 'reset'])
Пример #19
0
def get_new_command(command, settings):
    wrong = re.findall(r'`(\w+)` is not a heroku command', command.stderr)[0]
    correct = get_closest(wrong, _get_suggests(command.stderr))
    return command.script.replace(' {}'.format(wrong), ' {}'.format(correct), 1)
Пример #20
0
def get_new_command(command, settings):
    old_command = command.script.split(' ')[0]
    new_command = get_closest(old_command, get_all_executables())
    return ' '.join([new_command] + command.script.split(' ')[1:])
Пример #21
0
 def test_when_cant_match(self):
     assert 'status' == get_closest('st', ['status', 'reset'])
Пример #22
0
def get_new_command(command):
    return get_closest(command.script,
                       get_valid_history_without_current(command))
Пример #23
0
def get_new_command(command, settings):
    broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
                            command.stderr)[0]
    new_cmd = get_closest(broken_cmd,
                          _get_all_git_matched_commands(command.stderr))
    return replace_argument(command.script, broken_cmd, new_cmd)
Пример #24
0
def get_new_command(command):
    script = command.script_parts[:]
    possibilities = extract_possibilities(command)
    script[1] = get_closest(script[1], possibilities)
    return ' '.join(script)
Пример #25
0
def get_new_command(command, settings):
    wrong = re.findall(r'`(\w+)` is not a heroku command', command.stderr)[0]
    correct = get_closest(wrong, _get_suggests(command.stderr))
    return replace_argument(command.script, wrong, correct)
Пример #26
0
 def test_when_can_match(self):
     assert 'branch' == get_closest('brnch', ['branch', 'status'])
Пример #27
0
 def test_when_can_match(self):
     assert "branch" == get_closest("brnch", ["branch", "status"])
Пример #28
0
 def test_without_fallback(self):
     assert get_closest('st', ['status', 'reset'],
                        fallback_to_first=False) is None
Пример #29
0
 def test_without_fallback(self):
     assert get_closest("st", ["status", "reset"], fallback_to_first=False) is None
Пример #30
0
def _get_similar_formula(formula_name):
    return get_closest(formula_name, brew_formulas, 1, 0.85)
Пример #31
0
def get_new_command(command):
    return get_closest(command.script,
                       get_valid_history_without_current(command))
Пример #32
0
def get_new_command(command):
    script = command.script.split(' ')
    possibilities = extract_possibilities(command)
    script[1] = get_closest(script[1], possibilities)
    return ' '.join(script)
Пример #33
0
def get_new_command(command):
    npm_commands = _get_available_commands(command.stdout)
    wrong_command = _get_wrong_command(command.script_parts)
    fixed = get_closest(wrong_command, npm_commands)
    return replace_argument(command.script, wrong_command, fixed)
Пример #34
0
def _get_similar_formula(formula_name):
    return get_closest(formula_name, _get_formulas(), 1, 0.85)
Пример #35
0
 def test_without_fallback(self):
     assert get_closest('st', ['status', 'reset'],
                        fallback_to_first=False) is None
Пример #36
0
 def test_when_cant_match(self):
     assert "status" == get_closest("st", ["status", "reset"])
Пример #37
0
def _get_similar_command(command):
    return get_closest(command, brew_commands)
Пример #38
0
def get_new_command(command, settings):
    broken_cmd = re.findall(r'tsuru: "([^"]*)" is not a tsuru command',
                            command.stderr)[0]
    new_cmd = get_closest(broken_cmd,
                          get_all_matched_commands(command.stderr))
    return replace_argument(command.script, broken_cmd, new_cmd)
Пример #39
0
def get_new_command(command):
    closest_subcommand = get_closest(command.script_parts[1],
                                     get_golang_commands())
    return replace_argument(command.script, command.script_parts[1],
                            closest_subcommand)