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

Python utils.get_closest函数代码示例

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

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



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

示例1: 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


示例2: match

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


示例3: match

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


示例4: 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


示例5: match

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


示例6: 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.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:MJerty,项目名称:thefuck,代码行数:11,代码来源:git_checkout.py


示例7: get_new_command

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


示例8: get_new_command

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]
开发者ID:alexandre-paroissien,项目名称:thefuck,代码行数:19,代码来源:no_command.py


示例9: get_new_command

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


示例10: get_new_command

def get_new_command(command, settings):
    script = command.script.split(' ')
    possibilities = extract_possibilities(command)
    script[1] = get_closest(script[1], possibilities)
    return ' '.join(script)
开发者ID:roth1002,项目名称:thefuck,代码行数:5,代码来源:mercurial.py


示例11: 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


示例12: get_new_command

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


示例13: get_new_command

def get_new_command(command, settings):
    return get_closest(command.script,
                       _history_of_exists_without_current(command))
开发者ID:SanketDG,项目名称:thefuck,代码行数:3,代码来源:history.py


示例14: test_without_fallback

 def test_without_fallback(self):
     assert get_closest('st', ['status', 'reset'],
                        fallback_to_first=False) is None
开发者ID:ispiders,项目名称:thefuck,代码行数:3,代码来源:test_utils.py


示例15: _get_similar_formula

def _get_similar_formula(formula_name):
    return get_closest(formula_name, _get_formulas(), 1, 0.85)
开发者ID:MJerty,项目名称:thefuck,代码行数:2,代码来源:brew_install.py


示例16: test_when_can_match

 def test_when_can_match(self):
     assert 'branch' == get_closest('brnch', ['branch', 'status'])
开发者ID:ispiders,项目名称:thefuck,代码行数:2,代码来源:test_utils.py


示例17: test_when_cant_match

 def test_when_cant_match(self):
     assert 'status' == get_closest('st', ['status', 'reset'])
开发者ID:ispiders,项目名称:thefuck,代码行数:2,代码来源:test_utils.py


示例18: test_without_fallback

 def test_without_fallback(self):
     assert get_closest("st", ["status", "reset"], fallback_to_first=False) is None
开发者ID:liu4480,项目名称:thefuck,代码行数:2,代码来源:test_utils.py


示例19: get_new_command

def get_new_command(command):
    return get_closest(command.script,
                       get_valid_history_without_current(command))
开发者ID:alexandre-paroissien,项目名称:thefuck,代码行数:3,代码来源:history.py


示例20: get_new_command

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.replace_argument函数代码示例发布时间:2022-05-27
下一篇:
Python shells.and_函数代码示例发布时间: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