• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.replace_argument函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中thefuck.utils.replace_argument函数的典型用法代码示例。如果您正苦于以下问题:Python replace_argument函数的具体用法?Python replace_argument怎么用?Python replace_argument使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了replace_argument函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_new_command

def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.output)[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)
    elif command.script_parts[1] == 'checkout':
        return replace_argument(command.script, 'checkout', 'checkout -b')
    else:
        return shell.and_('git branch {}', '{}').format(
            missing_file, command.script)
开发者ID:Clpsplug,项目名称:thefuck,代码行数:13,代码来源:git_checkout.py


示例2: get_new_command

def get_new_command(command):
    destination = _get_destination(command)
    paths = _get_all_absolute_paths_from_history(command)

    return [replace_argument(command.script, destination, path)
            for path in paths if path.endswith(destination)
            and Path(path).expanduser().exists()]
开发者ID:Clpsplug,项目名称:thefuck,代码行数:7,代码来源:path_from_history.py


示例3: get_new_command

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)
开发者ID:Clpsplug,项目名称:thefuck,代码行数:7,代码来源:adb_unknown_command.py


示例4: get_new_command

def get_new_command(command):
    misspelled_task = regex.findall(command.output)[0]
    if misspelled_task in npm_commands:
        yarn_command = npm_commands[misspelled_task]
        return replace_argument(command.script, misspelled_task, yarn_command)
    else:
        tasks = _get_all_tasks()
        return replace_command(command, misspelled_task, tasks)
开发者ID:Clpsplug,项目名称:thefuck,代码行数:8,代码来源:yarn_command_not_found.py


示例5: get_new_command

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)
开发者ID:roth1002,项目名称:thefuck,代码行数:10,代码来源:git_fix_stash.py


示例6: get_new_command

def get_new_command(command, settings):
    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)
开发者ID:roth1002,项目名称:thefuck,代码行数:11,代码来源:git_checkout.py


示例7: get_new_command

def get_new_command(command):
    # If --set-upstream or -u are passed, remove it and its argument. This is
    # because the remaining arguments are concatenated onto the command suggested
    # by git, which includes --set-upstream and its argument
    command_parts = command.script_parts[:]
    upstream_option_index = _get_upstream_option_index(command_parts)

    if upstream_option_index is not None:
        command_parts.pop(upstream_option_index)

        # In case of `git push -u` we don't have next argument:
        if len(command_parts) > upstream_option_index:
            command_parts.pop(upstream_option_index)

    push_upstream = command.stderr.split('\n')[-3].strip().partition('git ')[2]
    return replace_argument(" ".join(command_parts), 'push', push_upstream)
开发者ID:Googulator,项目名称:thefuck,代码行数:16,代码来源:git_push.py


示例8: get_new_command

def get_new_command(command):
    # If --set-upstream or -u are passed, remove it and its argument. This is
    # because the remaining arguments are concatenated onto the command suggested
    # by git, which includes --set-upstream and its argument
    command_parts = command.script_parts[:]
    upstream_option_index = _get_upstream_option_index(command_parts)

    if upstream_option_index is not None:
        command_parts.pop(upstream_option_index)

        # In case of `git push -u` we don't have next argument:
        if len(command_parts) > upstream_option_index:
            command_parts.pop(upstream_option_index)

    arguments = re.findall(r'git push (.*)', command.output)[0].strip()
    return replace_argument(" ".join(command_parts), 'push',
                            'push {}'.format(arguments))
开发者ID:yongbinfeng,项目名称:thefuck,代码行数:17,代码来源:git_push.py


示例9: get_new_command

def get_new_command(command):
    # If --set-upstream or -u are passed, remove it and its argument. This is
    # because the remaining arguments are concatenated onto the command suggested
    # by git, which includes --set-upstream and its argument
    command_parts = command.script_parts[:]
    upstream_option_index = _get_upstream_option_index(command_parts)

    if upstream_option_index is not None:
        command_parts.pop(upstream_option_index)

        # In case of `git push -u` we don't have next argument:
        if len(command_parts) > upstream_option_index:
            command_parts.pop(upstream_option_index)
    else:
        # the only non-qualified permitted options are the repository and refspec; git's
        # suggestion include them, so they won't be lost, but would be duplicated otherwise.
        push_idx = command_parts.index('push') + 1
        while len(command_parts) > push_idx and command_parts[len(command_parts) - 1][0] != '-':
            command_parts.pop(len(command_parts) - 1)

    arguments = re.findall(r'git push (.*)', command.output)[0].replace("'", r"\'").strip()
    return replace_argument(" ".join(command_parts), 'push',
                            'push {}'.format(arguments))
开发者ID:Clpsplug,项目名称:thefuck,代码行数:23,代码来源:git_push.py


示例10: get_new_command

def get_new_command(command):
    to = command.stderr.split('`')[1]
    return replace_argument(command.script, to[1:], to)
开发者ID:AdmiralAwesome,项目名称:thefuck,代码行数:3,代码来源:git_two_dashes.py


示例11: get_new_command

def get_new_command(command, settings):
    return replace_argument(command.script, 'pull', 'clone')
开发者ID:Aftermath,项目名称:thefuck,代码行数:2,代码来源:git_pull_clone.py


示例12: get_new_command

def get_new_command(command):
    not_exist_formula = re.findall(r'Error: No available formula for ([a-z]+)',
                                   command.stderr)[0]
    exist_formula = _get_similar_formula(not_exist_formula)

    return replace_argument(command.script, not_exist_formula, exist_formula)
开发者ID:MJerty,项目名称:thefuck,代码行数:6,代码来源:brew_install.py


示例13: get_new_command

def get_new_command(command, settings):
    return shells.and_(replace_argument(command.script, "push", "pull"), command.script)
开发者ID:Aftermath,项目名称:thefuck,代码行数:2,代码来源:git_push_pull.py


示例14: get_new_command

def get_new_command(command):
    return replace_argument(command.script, 'add', 'add --force')
开发者ID:Googulator,项目名称:thefuck,代码行数:2,代码来源:git_add_force.py


示例15: test_replace_argument

def test_replace_argument(args, result):
    assert replace_argument(*args) == result
开发者ID:liu4480,项目名称:thefuck,代码行数:2,代码来源:test_utils.py


示例16: get_new_command

def get_new_command(command, settings):
    broken = command.script.split()[1]
    fix = re.findall(r'Did you mean `([^`]*)`', command.stderr)[0]

    return replace_argument(command.script, broken, fix)
开发者ID:SanketDG,项目名称:thefuck,代码行数:5,代码来源:cargo_no_command.py


示例17: get_new_command

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)
开发者ID:SanketDG,项目名称:thefuck,代码行数:5,代码来源:docker_not_command.py


示例18: get_new_command

def get_new_command(command):
    broken_cmd = re.findall(r'ERROR: unknown command \"([a-z]+)\"',
                            command.stderr)[0]
    new_cmd = re.findall(r'maybe you meant \"([a-z]+)\"', command.stderr)[0]

    return replace_argument(command.script, broken_cmd, new_cmd)
开发者ID:Googulator,项目名称:thefuck,代码行数:6,代码来源:pip_unknown_command.py


示例19: get_new_command

def get_new_command(command):
    return shell.and_(replace_argument(command.script, 'push', 'pull'),
                      command.script)
开发者ID:Clpsplug,项目名称:thefuck,代码行数:3,代码来源:git_push_pull.py


示例20: get_new_command

def get_new_command(command):
    broken_cmd = re.findall(r"Command \"([^']*)\" is not defined", command.stderr)[0]
    new_cmd = re.findall(r'Did you mean this\?[^\n]*\n\s*([^\n]*)', command.stderr)
    if not new_cmd:
        new_cmd = re.findall(r'Did you mean one of these\?[^\n]*\n\s*([^\n]*)', command.stderr)
    return replace_argument(command.script, broken_cmd, new_cmd[0].strip())
开发者ID:AdmiralAwesome,项目名称:thefuck,代码行数:6,代码来源:composer_not_command.py



注:本文中的thefuck.utils.replace_argument函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.replace_command函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_closest函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap