当前位置: 首页>>代码示例>>Python>>正文


Python ActionAliasFormatParser.get_extracted_param_value方法代码示例

本文整理汇总了Python中st2common.models.utils.action_alias_utils.ActionAliasFormatParser.get_extracted_param_value方法的典型用法代码示例。如果您正苦于以下问题:Python ActionAliasFormatParser.get_extracted_param_value方法的具体用法?Python ActionAliasFormatParser.get_extracted_param_value怎么用?Python ActionAliasFormatParser.get_extracted_param_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st2common.models.utils.action_alias_utils.ActionAliasFormatParser的用法示例。


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

示例1: test_key_value_combinations

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
    def test_key_value_combinations(self):
        # one-word value, single extra pair
        alias_format = 'testing {{ a }}'
        param_stream = 'testing value b=value2'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'value',
                                            'b': 'value2'})

        # default value, single extra pair with quotes
        alias_format = 'testing {{ a=new }}'
        param_stream = 'testing b="another value"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'new',
                                            'b': 'another value'})

        # multiple values and multiple extra pairs
        alias_format = 'testing {{ b=abc }} {{ c=xyz }}'
        param_stream = 'testing newvalue d={"1": "2"} e="long value"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'b': 'newvalue',
                                            'c': 'xyz',
                                            'd': '{"1": "2"}',
                                            'e': 'long value'})
开发者ID:Bala96,项目名称:st2,代码行数:28,代码来源:test_action_alias_utils.py

示例2: test_regex_beginning_and_ending_anchors_dont_match

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
    def test_regex_beginning_and_ending_anchors_dont_match(self):
        alias_format = r'^\s*foo (?P<issue_key>[A-Z][A-Z0-9]+-[0-9]+)\s*$'
        param_stream = 'bar ASDF-1234'
        parser = ActionAliasFormatParser(alias_format, param_stream)

        expected_msg = r'''Command "bar ASDF-1234" doesn't match format string '''\
                       r'''"^\s*foo (?P<issue_key>[A-Z][A-Z0-9]+-[0-9]+)\s*$"'''
        with self.assertRaises(ParseException) as e:
            parser.get_extracted_param_value()

            self.assertEqual(e.msg, expected_msg)
开发者ID:StackStorm,项目名称:st2,代码行数:13,代码来源:test_action_alias_utils.py

示例3: test_enclosed_defaults

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
    def test_enclosed_defaults(self):
        alias_format = 'skip {{ a = value }} more'
        param_stream = 'skip one more'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'one'})

        alias_format = 'skip {{ a = value }} more'
        param_stream = 'skip more'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'value'})
开发者ID:Bala96,项目名称:st2,代码行数:14,代码来源:test_action_alias_utils.py

示例4: test_param_spaces

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_param_spaces(self):
     alias_format = 's {{a}} more {{ b }} more {{ c=99 }} more {{ d = 99 }}'
     param_stream = 's one more two more three more'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': 'one', 'b': 'two',
                                         'c': 'three', 'd': '99'})
开发者ID:Bala96,项目名称:st2,代码行数:9,代码来源:test_action_alias_utils.py

示例5: test_mixed_parsing

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_mixed_parsing(self):
     alias_format = 'skip {{a}} more skip {{b}}.'
     param_stream = 'skip {"a": "b", "c": "d"} more skip x.'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': '{"a": "b", "c": "d"}',
                                         'b': 'x'})
开发者ID:Bala96,项目名称:st2,代码行数:9,代码来源:test_action_alias_utils.py

示例6: test_default_values

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_default_values(self):
     alias_format = 'acl {{a}} {{b}} {{c}} {{d=1}}'
     param_stream = 'acl "a1 a2" "b1" "c1"'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': 'a1 a2', 'b': 'b1',
                                         'c': 'c1', 'd': '1'})
开发者ID:Bala96,项目名称:st2,代码行数:9,代码来源:test_action_alias_utils.py

示例7: test_all_the_things

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_all_the_things(self):
     # this is the most insane example I could come up with
     alias_format = "{{ p0='http' }} g {{ p1=p }} a " + \
                    "{{ url }} {{ p2={'a':'b'} }} {{ p3={{ e.i }} }}"
     param_stream = "g a http://google.com {{ execution.id }} p4='testing' p5={'a':'c'}"
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'p0': 'http', 'p1': 'p',
                                         'url': 'http://google.com',
                                         'p2': '{{ execution.id }}',
                                         'p3': '{{ e.i }}',
                                         'p4': 'testing', 'p5': "{'a':'c'}"})
开发者ID:Bala96,项目名称:st2,代码行数:14,代码来源:test_action_alias_utils.py

示例8: test_arbitrary_pairs

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
    def test_arbitrary_pairs(self):
        # single-word param
        alias_format = ''
        param_stream = 'a=foobar1'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1'})

        # multi-word double-quoted param
        alias_format = 'foo'
        param_stream = 'foo a="foobar2 poonies bar"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar2 poonies bar'})

        # multi-word single-quoted param
        alias_format = 'foo'
        param_stream = 'foo a=\'foobar2 poonies bar\''
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar2 poonies bar'})

        # JSON param
        alias_format = 'foo'
        param_stream = 'foo a={"foobar2": "poonies"}'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': '{"foobar2": "poonies"}'})

        # Multiple mixed params
        alias_format = ''
        param_stream = 'a=foobar1 b="boobar2 3 4" c=\'coobar3 4\' d={"a": "b"}'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1',
                                            'b': 'boobar2 3 4',
                                            'c': 'coobar3 4',
                                            'd': '{"a": "b"}'})

        # Params along with a "normal" alias format
        alias_format = '{{ captain }} is my captain'
        param_stream = 'Malcolm Reynolds is my captain weirdo="River Tam"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'captain': 'Malcolm Reynolds',
                                            'weirdo': 'River Tam'})
开发者ID:Bala96,项目名称:st2,代码行数:48,代码来源:test_action_alias_utils.py

示例9: test_end_string_parsing

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_end_string_parsing(self):
     alias_format = 'skip {{a}} more skip {{b}}'
     param_stream = 'skip a1 more skip b1'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': 'a1', 'b': 'b1'})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例10: test_ending_parameters_matching

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_ending_parameters_matching(self):
     alias_format = 'foo bar'
     param_stream = 'foo bar pony1=foo pony2=bar'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'pony1': 'foo', 'pony2': 'bar'})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例11: test_empty_string

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_empty_string(self):
     alias_format = ''
     param_stream = ''
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例12: test_stream_is_not_none_some_default_values

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_stream_is_not_none_some_default_values(self):
     alias_format = 'skip {{d=test}} more skip {{e=test}}'
     param_stream = 'skip ponies more skip'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'d': 'ponies', 'e': 'test'})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例13: test_template_defaults

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_template_defaults(self):
     alias_format = 'two by two hands of {{ color = {{ colors.default_color }} }}'
     param_stream = 'two by two hands of'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'color': '{{ colors.default_color }}'})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例14: test_spacing

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
 def test_spacing(self):
     alias_format = 'acl {{a=test}}'
     param_stream = 'acl'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': 'test'})
开发者ID:Bala96,项目名称:st2,代码行数:8,代码来源:test_action_alias_utils.py

示例15: test_default_key_value_param_parsing

# 需要导入模块: from st2common.models.utils.action_alias_utils import ActionAliasFormatParser [as 别名]
# 或者: from st2common.models.utils.action_alias_utils.ActionAliasFormatParser import get_extracted_param_value [as 别名]
    def test_default_key_value_param_parsing(self):
        # Empty string
        alias_format = ''
        param_stream = ''
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {})

        # 1 key value pair provided in the param stream
        alias_format = ''
        param_stream = 'a=foobar1'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1'})

        alias_format = ''
        param_stream = 'foo a=foobar2 poonies bar'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar2'})

        # Multiple params provided
        alias_format = ''
        param_stream = 'a=foobar1 b=boobar2 c=coobar3'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1', 'b': 'boobar2', 'c': 'coobar3'})

        # Multiple params provided
        alias_format = ''
        param_stream = 'a=foobar4 b=boobar5 c=coobar6'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar4', 'b': 'boobar5', 'c': 'coobar6'})

        # Multiple params provided
        alias_format = ''
        param_stream = 'mixed a=foobar1 some more b=boobar2 text c=coobar3 yeah'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1', 'b': 'boobar2', 'c': 'coobar3'})

        # Param with quotes, make sure they are stripped
        alias_format = ''
        param_stream = 'mixed a="foobar1"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1'})

        # Param with quotes, make sure they are stripped
        alias_format = ''
        param_stream = 'mixed a="foobar test" ponies a'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar test'})

        # Param with quotes, make sure they are stripped
        alias_format = ''
        param_stream = "mixed a='foobar1 ponies' test"
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1 ponies'})

        # Param with quotes, make sure they are stripped
        alias_format = ''
        param_stream = 'mixed a="foobar1"'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar1'})

        # Mixed format and kv params
        alias_format = 'somestuff {{a}} more stuff {{b}}'
        param_stream = 'somestuff a=foobar more stuff coobar'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'foobar', 'b': 'coobar'})

        alias_format = 'somestuff {{a}} more stuff {{b}}'
        param_stream = 'somestuff ponies more stuff coobar'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'ponies', 'b': 'coobar'})

        alias_format = 'somestuff {{a}} more stuff {{b}}'
        param_stream = 'somestuff ponies more stuff coobar b=foo'
        parser = ActionAliasFormatParser(alias_format, param_stream)
        extracted_values = parser.get_extracted_param_value()
        self.assertEqual(extracted_values, {'a': 'ponies', 'b': 'foo'})
开发者ID:hejin,项目名称:st2,代码行数:90,代码来源:test_action_alias_utils.py


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