本文整理汇总了Python中cliff.app.App.get_fuzzy_matches方法的典型用法代码示例。如果您正苦于以下问题:Python App.get_fuzzy_matches方法的具体用法?Python App.get_fuzzy_matches怎么用?Python App.get_fuzzy_matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cliff.app.App
的用法示例。
在下文中一共展示了App.get_fuzzy_matches方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fuzzy_no_prefix
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import get_fuzzy_matches [as 别名]
def test_fuzzy_no_prefix():
# search by distance, no common prefix with any command
cmd_mgr = CommandManager('cliff.fuzzy')
app = App('test', '1.0', cmd_mgr)
cmd_mgr.add_command('user', utils.TestCommand)
matches = app.get_fuzzy_matches('uesr')
assert matches == ['user']
示例2: test_fuzzy_common_prefix
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import get_fuzzy_matches [as 别名]
def test_fuzzy_common_prefix():
# searched string is a prefix of all commands
cmd_mgr = CommandManager('cliff.fuzzy')
app = App('test', '1.0', cmd_mgr)
cmd_mgr.commands = {}
cmd_mgr.add_command('user list', utils.TestCommand)
cmd_mgr.add_command('user show', utils.TestCommand)
matches = app.get_fuzzy_matches('user')
assert matches == ['user list', 'user show']
示例3: test_fuzzy_same_distance
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import get_fuzzy_matches [as 别名]
def test_fuzzy_same_distance():
# searched string has the same distance to all commands
cmd_mgr = CommandManager('cliff.fuzzy')
app = App('test', '1.0', cmd_mgr)
cmd_mgr.add_command('user', utils.TestCommand)
for cmd in cmd_mgr.commands.keys():
assert damerau_levenshtein('node', cmd, COST) == 8
matches = app.get_fuzzy_matches('node')
assert matches == ['complete', 'help', 'user']
示例4: test_fuzzy_no_commands
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import get_fuzzy_matches [as 别名]
def test_fuzzy_no_commands():
cmd_mgr = CommandManager('cliff.fuzzy')
app = App('test', '1.0', cmd_mgr)
cmd_mgr.commands = {}
matches = app.get_fuzzy_matches('foo')
assert matches == []