本文整理汇总了Python中explainshell.matcher.matcher函数的典型用法代码示例。如果您正苦于以下问题:Python matcher函数的具体用法?Python matcher怎么用?Python matcher使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了matcher函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_functions
def test_functions(self):
cmd = 'function a() { bar; }'
shellresults = [(0, 14, helpconstants._function, 'function a() {'),
(18, 19, helpconstants.OPSEMICOLON, ';'),
(20, 21, helpconstants._function, '}'),]
matchresults = [(15, 18, 'bar synopsis', 'bar')]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, shellresults)
self.assertEquals(groups[1].results, matchresults)
cmd = 'function a() { bar "$(a)"; }'
shellresults = [(0, 14, helpconstants._function, 'function a() {'),
(25, 26, helpconstants.OPSEMICOLON, ';'),
(27, 28, helpconstants._function, '}'),]
matchresults = [(15, 18, 'bar synopsis', 'bar'),
(19, 25, None, '"$(a)"')]
m = matcher.matcher(cmd, s)
groups = m.match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, shellresults)
self.assertEquals(groups[1].results, matchresults)
self.assertEquals(m.expansions, [(22, 23, 'substitution')])
开发者ID:bitzhuxb,项目名称:explainshell,代码行数:28,代码来源:test-matcher.py
示例2: test_multicommand
def test_multicommand(self):
cmd = 'bar baz --b foo'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 7, None, 'baz'),
(8, 15, '-b <arg> desc', '--b foo')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
cmd = 'bar foo --b foo'
matchedresult = ('bar-foo', [
(0, 7, 'bar foo synopsis', 'bar foo'),
(8, 15, '-b <arg> desc', '--b foo')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:15,代码来源:test-matcher.py
示例3: test_arg_with_expected_value_from_list
def test_arg_with_expected_value_from_list(self):
cmd = 'bar -c one'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 10, '-c=one,two\ndesc', '-c one')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
cmd = 'bar -c notinlist'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 6, '-c=one,two\ndesc', '-c'),
(7, 16, None, 'notinlist')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:15,代码来源:test-matcher.py
示例4: test_long
def test_long(self):
cmd = 'bar --b=b'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 9, '-b <arg> desc', '--b=b')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:7,代码来源:test-matcher.py
示例5: test_unknown_arg
def test_unknown_arg(self):
matchedresult = ('bar', [(0, 3, 'bar synopsis', 'bar'), (4, 6, None, '-x')])
self.assertEquals(matcher.matcher('bar -x', s).match(), [matchedresult])
# merges
matchedresult = ('bar', [(0, 3, 'bar synopsis', 'bar'), (4, 10, None, '-x --x')])
self.assertEquals(matcher.matcher('bar -x --x', s).match(), [matchedresult])
matchedresult = ('bar', [(0, 3, 'bar synopsis', 'bar'), (4, 8, None, '-xyz')])
self.assertEquals(matcher.matcher('bar -xyz', s).match(), [matchedresult])
matchedresult = ('bar', [(0, 3, 'bar synopsis', 'bar'),
(4, 6, None, '-x'),
(6, 7, '-a desc', 'a'), (7, 8, None, 'z')])
self.assertEquals(matcher.matcher('bar -xaz', s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:16,代码来源:test-matcher.py
示例6: test_arg_with_expected_value
def test_arg_with_expected_value(self):
cmd = 'bar -b arg --b arg'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 18, '-b <arg> desc', '-b arg --b arg')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:7,代码来源:test-matcher.py
示例7: test_known_arg
def test_known_arg(self):
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 10, '-a desc', '-a --a'),
(11, 13, '-? help text', '-?')])
self.assertEquals(matcher.matcher('bar -a --a -?', s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:7,代码来源:test-matcher.py
示例8: test
def test(self):
mngr = manager.manager('localhost', 'explainshell_tests', [os.path.join(os.path.dirname(__file__), 'echo.1.gz')], drop=True)
mngr.run()
cmd = 'echo -en foobar --version'
m = matcher.matcher(cmd, mngr.store)
matchprog, matches = m.match()[0]
self.assertEquals(matchprog, 'echo')
#self.assertEquals(matches[0].text, 'display a line of text')
self.assertEquals(matches[0].match, 'echo')
self.assertEquals(matches[1].text, '<b>-e</b> enable interpretation of backslash escapes')
self.assertEquals(matches[1].match, '-e')
self.assertEquals(matches[2].text, '<b>-n</b> do not output the trailing newline')
self.assertEquals(matches[2].match, 'n')
self.assertEquals(matches[3].text, None)
self.assertEquals(matches[3].match, 'foobar')
self.assertEquals(matches[4].text, '<b>--version</b>\n output version information and exit')
self.assertEquals(matches[4].match, '--version')
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:25,代码来源:test-integration.py
示例9: test_arg_in_fuzzy_with_expected_value
def test_arg_in_fuzzy_with_expected_value(self):
cmd = 'baz -ab arg'
matchedresult = ('baz', [
(0, 3, 'baz synopsis', 'baz'),
(4, 6, '-a desc', '-a'),
(6, 11, '-b <arg> desc', 'b arg')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:8,代码来源:test-matcher.py
示例10: test_arg_with_expected_value_clash
def test_arg_with_expected_value_clash(self):
'''the first option expects an arg but the arg is actually an option'''
cmd = 'bar -b -a'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 6, '-b <arg> desc', '-b'),
(7, 9, '-a desc', '-a')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:9,代码来源:test-matcher.py
示例11: test_pipe
def test_pipe(self):
cmd = 'bar | baz'
matchedresult = [[(4, 5, helpconstants.PIPELINES, '|')],
[(0, 3, 'bar synopsis', 'bar')],
[(6, 9, 'baz synopsis', 'baz')]]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(groups[0].results, matchedresult[0])
self.assertEquals(groups[1].results, matchedresult[1])
开发者ID:adamhut,项目名称:explainshell,代码行数:9,代码来源:test-matcher.py
示例12: test_arg_no_dash
def test_arg_no_dash(self):
cmd = 'baz ab -x'
matchedresult = ('baz', [
(0, 3, 'baz synopsis', 'baz'),
(4, 5, '-a desc', 'a'),
(5, 6, '-b <arg> desc', 'b'),
(7, 9, None, '-x')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:9,代码来源:test-matcher.py
示例13: test_arg_is_dash
def test_arg_is_dash(self):
cmd = 'bar -b - -a -'
matchedresult = ('bar', [
(0, 3, 'bar synopsis', 'bar'),
(4, 8, '-b <arg> desc', '-b -'),
(9, 11, '-a desc', '-a'),
(12, 13, None, '-')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:9,代码来源:test-matcher.py
示例14: test_redirect_first_word_of_command
def test_redirect_first_word_of_command(self):
cmd = '2>&1'
matchedresult = [(0, 4, helpconstants.REDIRECTION + '\n\n' +
helpconstants.REDIRECTION_KIND['>'], '2>&1')]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 1)
self.assertEquals(groups[0].results, matchedresult)
cmd = '2>&1 bar'
matchedresult = [[(0, 4, helpconstants.REDIRECTION + '\n\n' +
helpconstants.REDIRECTION_KIND['>'], '2>&1')],
[(5, 8, 'bar synopsis', 'bar')]]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, matchedresult[0])
self.assertEquals(groups[1].results, matchedresult[1])
开发者ID:adamhut,项目名称:explainshell,代码行数:18,代码来源:test-matcher.py
示例15: test_multiple_matches
def test_multiple_matches(self):
cmd = 'dup -ab'
matchedresult = ('dup', [
(0, 3, 'dup1 synopsis', 'dup'),
(4, 6, '-a desc', '-a'),
(6, 7, '-b <arg> desc', 'b')])
mr = matcher.matcher(cmd, s).match()
self.assertEquals(mr[0], matchedresult)
self.assertEquals(mr[1][0].source, 'dup.2.gz')
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
示例16: test_assignment_with_expansion
def test_assignment_with_expansion(self):
cmd = 'a="$1" bar'
shellresults = [(0, 6, helpconstants.ASSIGNMENT, 'a="$1"')]
matchresults = [[(7, 10, 'bar synopsis', 'bar')]]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, shellresults)
self.assertEquals(groups[1].results, matchresults[0])
开发者ID:bitzhuxb,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
示例17: test_assignment_as_first_word
def test_assignment_as_first_word(self):
cmd = 'a=b bar'
shellresults = [(0, 3, helpconstants.ASSIGNMENT, 'a=b')]
matchresults = [(4, 7, 'bar synopsis', 'bar')]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, shellresults)
self.assertEquals(groups[1].results, matchresults)
开发者ID:bitzhuxb,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
示例18: test_arguments
def test_arguments(self):
cmd = 'withargs -x -b freearg freearg'
matchedresult = ('withargs', [
(0, 8, 'withargs synopsis', 'withargs'),
# tokens that look like options are still unknown
(9, 11, None, '-x'),
(12, 22, '-b <arg> desc', '-b freearg'),
(23, 30, 'FILE argument', 'freearg')])
self.assertEquals(matcher.matcher(cmd, s).match(), [matchedresult])
开发者ID:OmarIthawi,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
示例19: test_no_synopsis
def test_no_synopsis(self):
cmd = 'nosynopsis a'
matchresults = [(0, 10, helpconstants.NOSYNOPSIS, 'nosynopsis'),
(11, 12, None, 'a')]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(len(groups), 2)
self.assertEquals(groups[0].results, [])
self.assertEquals(groups[1].results, matchresults)
开发者ID:DigNative,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
示例20: test_multiple_matches
def test_multiple_matches(self):
cmd = 'dup -ab'
matchedresult = [
(0, 3, 'dup1 synopsis', 'dup'),
(4, 6, '-a desc', '-a'),
(6, 7, '-b <arg> desc', 'b')]
groups = matcher.matcher(cmd, s).match()
self.assertEquals(groups[1].results, matchedresult)
self.assertEquals(groups[1].suggestions[0].source, 'dup.2.gz')
开发者ID:adamhut,项目名称:explainshell,代码行数:10,代码来源:test-matcher.py
注:本文中的explainshell.matcher.matcher函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论