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

Python action_alias_utils.ActionAliasFormatParser类代码示例

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

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



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

示例1: test_param_spaces

 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,代码行数:7,代码来源:test_action_alias_utils.py


示例2: test_mixed_parsing

 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,代码行数:7,代码来源:test_action_alias_utils.py


示例3: test_default_values

 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,代码行数:7,代码来源:test_action_alias_utils.py


示例4: test_regex_beginning_and_ending_anchors_dont_match

    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,代码行数:11,代码来源:test_action_alias_utils.py


示例5: test_all_the_things

 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,代码行数:12,代码来源:test_action_alias_utils.py


示例6: test_enclosed_defaults

    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,代码行数:12,代码来源:test_action_alias_utils.py


示例7: test_key_value_combinations

    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,代码行数:26,代码来源:test_action_alias_utils.py


示例8: test_end_string_parsing

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例9: test_arbitrary_pairs

    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,代码行数:46,代码来源:test_action_alias_utils.py


示例10: test_ending_parameters_matching

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例11: test_empty_string

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例12: test_stream_is_not_none_some_default_values

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例13: test_template_defaults

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例14: test_spacing

 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,代码行数:6,代码来源:test_action_alias_utils.py


示例15: test_default_key_value_param_parsing

    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,代码行数:88,代码来源:test_action_alias_utils.py


示例16: test_spaced_parsing

 def test_spaced_parsing(self):
     alias_format = 'skip {{a}} more skip {{b}} and skip more.'
     param_stream = 'skip "a1 a2" more skip b1 and skip more.'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'a': 'a1 a2', 'b': 'b1'})
开发者ID:Bala96,项目名称:st2,代码行数:6,代码来源:test_action_alias_utils.py


示例17: test_stream_is_none_with_all_default_values

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


示例18: test_regex_beginning_and_ending_anchors

 def test_regex_beginning_and_ending_anchors(self):
     alias_format = r'^\s*foo (?P<issue_key>[A-Z][A-Z0-9]+-[0-9]+) bar\s*$'
     param_stream = 'foo ASDF-1234 bar'
     parser = ActionAliasFormatParser(alias_format, param_stream)
     extracted_values = parser.get_extracted_param_value()
     self.assertEqual(extracted_values, {'issue_key': 'ASDF-1234'})
开发者ID:StackStorm,项目名称:st2,代码行数:6,代码来源:test_action_alias_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python operators.get_operator函数代码示例发布时间:2022-05-27
下一篇:
Python common.ResourceReference类代码示例发布时间: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