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

Python lint.preprocess_options函数代码示例

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

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



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

示例1: test_error_missing_expected_value

 def test_error_missing_expected_value(self):
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(['--foo', '--bar', '--qu=ux'],
                            {'bar': (None, True)})
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(['--foo', '--bar'],
                            {'bar': (None, True)})
开发者ID:Mariatta,项目名称:pylint,代码行数:7,代码来源:unittest_lint.py


示例2: test_value_equal

 def test_value_equal(self):
     self.args = []
     preprocess_options(['--foo', '--bar=baz', '--qu=ux'],
                        {'foo' : (self._callback, False),
                         'qu' : (self._callback, True)})
     self.assertEqual(
         [('foo', None), ('qu', 'ux')], self.args)
开发者ID:The-Compiler,项目名称:pylint,代码行数:7,代码来源:unittest_lint.py


示例3: test_value_equal

 def test_value_equal(self):
     self.args = []
     preprocess_options(
         ["--foo", "--bar=baz", "--qu=ux"],
         {"foo": (self._callback, False), "qu": (self._callback, True)},
     )
     assert [("foo", None), ("qu", "ux")] == self.args
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:7,代码来源:unittest_lint.py


示例4: test_value_space

 def test_value_space(self):
     self.args = []
     preprocess_options(['--qu', 'ux'],
                        {'qu' : (self._callback, True)})
     self.assertEqual(
         [('qu', 'ux')], self.args)
开发者ID:The-Compiler,项目名称:pylint,代码行数:6,代码来源:unittest_lint.py


示例5: __init__

        def __init__(self, args, reporter=None):
            self._rcfile = None
            self._plugins = []
            preprocess_options(
                args,
                {
                    # option: (callback, takearg)
                    "rcfile": (self.cb_set_rcfile, True),
                    "load-plugins": (self.cb_add_plugins, True),
                },
            )
            self.linter = linter = self.LinterClass(
                (
                    (
                        "rcfile",
                        {
                            "action": "callback",
                            "callback": lambda *args: 1,
                            "type": "string",
                            "metavar": "<file>",
                            "help": "Specify a configuration file.",
                        },
                    ),
                    (
                        "init-hook",
                        {
                            "action": "callback",
                            "type": "string",
                            "metavar": "<code>",
                            "callback": cb_init_hook,
                            "help": "Python code to execute, usually for sys.path \
    manipulation such as pygtk.require().",
                        },
                    ),
                    (
                        "help-msg",
                        {
                            "action": "callback",
                            "type": "string",
                            "metavar": "<msg-id>",
                            "callback": self.cb_help_message,
                            "group": "Commands",
                            "help": """Display a help message for the given message id and \
    exit. The value may be a comma separated list of message ids.""",
                        },
                    ),
                    (
                        "list-msgs",
                        {
                            "action": "callback",
                            "metavar": "<msg-id>",
                            "callback": self.cb_list_messages,
                            "group": "Commands",
                            "help": "Generate pylint's full documentation.",
                        },
                    ),
                    (
                        "generate-rcfile",
                        {
                            "action": "callback",
                            "callback": self.cb_generate_config,
                            "group": "Commands",
                            "help": """Generate a sample configuration file according to \
    the current configuration. You can put other options before this one to get \
    them in the generated configuration.""",
                        },
                    ),
                    (
                        "generate-man",
                        {
                            "action": "callback",
                            "callback": self.cb_generate_manpage,
                            "group": "Commands",
                            "help": "Generate pylint's man page.",
                            "hide": "True",
                        },
                    ),
                    (
                        "errors-only",
                        {
                            "action": "callback",
                            "callback": self.cb_error_mode,
                            "short": "e",
                            "help": """In error mode, checkers without error messages are \
    disabled and for others, only the ERROR messages are displayed, and no reports \
    are done by default""",
                        },
                    ),
                    ("profile", {"type": "yn", "metavar": "<y_or_n>", "default": False, "help": "Profiled execution."}),
                ),
                option_groups=self.option_groups,
                reporter=reporter,
                pylintrc=self._rcfile,
            )
            # register standard checkers
            checkers.initialize(linter)
            # load command line plugins
            linter.load_plugin_modules(self._plugins)
            # read configuration
            linter.disable_message("W0704")
#.........这里部分代码省略.........
开发者ID:lat,项目名称:WMCore,代码行数:101,代码来源:setup_test.py


示例6: test_error_unexpected_value

 def test_error_unexpected_value(self):
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(['--foo', '--bar=spam', '--qu=ux'],
                            {'bar': (None, False)})
开发者ID:Mariatta,项目名称:pylint,代码行数:4,代码来源:unittest_lint.py


示例7: __init__

        def __init__(self, args, reporter=None):
            self._rcfile = None
            self._plugins = []
            preprocess_options(args, {
                # option: (callback, takearg)
                'rcfile':       (self.cb_set_rcfile, True),
                'load-plugins': (self.cb_add_plugins, True),
                })
            self.linter = linter = self.LinterClass((
                ('rcfile',
                 {'action' : 'callback', 'callback' : lambda *args: 1,
                  'type': 'string', 'metavar': '<file>',
                  'help' : 'Specify a configuration file.'}),

                ('init-hook',
                 {'action' : 'callback', 'type' : 'string', 'metavar': '<code>',
                  'callback' : cb_init_hook,
                  'help' : 'Python code to execute, usually for sys.path \
    manipulation such as pygtk.require().'}),

                ('help-msg',
                 {'action' : 'callback', 'type' : 'string', 'metavar': '<msg-id>',
                  'callback' : self.cb_help_message,
                  'group': 'Commands',
                  'help' : '''Display a help message for the given message id and \
    exit. The value may be a comma separated list of message ids.'''}),

                ('list-msgs',
                 {'action' : 'callback', 'metavar': '<msg-id>',
                  'callback' : self.cb_list_messages,
                  'group': 'Commands',
                  'help' : "Generate pylint's full documentation."}),

                ('generate-rcfile',
                 {'action' : 'callback', 'callback' : self.cb_generate_config,
                  'group': 'Commands',
                  'help' : '''Generate a sample configuration file according to \
    the current configuration. You can put other options before this one to get \
    them in the generated configuration.'''}),

                ('generate-man',
                 {'action' : 'callback', 'callback' : self.cb_generate_manpage,
                  'group': 'Commands',
                  'help' : "Generate pylint's man page.",'hide': 'True'}),

                ('errors-only',
                 {'action' : 'callback', 'callback' : self.cb_error_mode,
                  'short': 'e',
                  'help' : '''In error mode, checkers without error messages are \
    disabled and for others, only the ERROR messages are displayed, and no reports \
    are done by default'''}),

                ('profile',
                 {'type' : 'yn', 'metavar' : '<y_or_n>',
                  'default': False,
                  'help' : 'Profiled execution.'}),

                ), option_groups=self.option_groups,
                   reporter=reporter, pylintrc=self._rcfile)
            # register standard checkers
            checkers.initialize(linter)
            # load command line plugins
            linter.load_plugin_modules(self._plugins)
            # read configuration
            linter.disable_message('W0704')
            linter.read_config_file()
            # is there some additional plugins in the file configuration, in
            config_parser = linter._config_parser
            if config_parser.has_option('MASTER', 'load-plugins'):
                plugins = splitstrip(config_parser.get('MASTER', 'load-plugins'))
                linter.load_plugin_modules(plugins)
            # now we can load file config and command line, plugins (which can
            # provide options) have been registered
            linter.load_config_file()
            if reporter:
                # if a custom reporter is provided as argument, it may be overriden
                # by file parameters, so re-set it here, but before command line
                # parsing so it's still overrideable by command line option
                linter.set_reporter(reporter)
            args = linter.load_command_line_configuration(args)
            # insert current working directory to the python path to have a correct
            # behaviour
            sys.path.insert(0, os.getcwd())
            if self.linter.config.profile:
                print >> sys.stderr, '** profiled run'
                from hotshot import Profile, stats
                prof = Profile('stones.prof')
                prof.runcall(linter.check, args)
                prof.close()
                data = stats.load('stones.prof')
                data.strip_dirs()
                data.sort_stats('time', 'calls')
                data.print_stats(30)
            sys.path.pop(0)
开发者ID:zhiwenuil,项目名称:WMCore,代码行数:94,代码来源:setup_test.py


示例8: test_error_unexpected_value

 def test_error_unexpected_value(self):
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(
             ["--foo", "--bar=spam", "--qu=ux"], {"bar": (None, False)}
         )
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:5,代码来源:unittest_lint.py


示例9: test_error_missing_expected_value

 def test_error_missing_expected_value(self):
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(["--foo", "--bar", "--qu=ux"], {"bar": (None, True)})
     with pytest.raises(ArgumentPreprocessingError):
         preprocess_options(["--foo", "--bar"], {"bar": (None, True)})
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:5,代码来源:unittest_lint.py


示例10: test_value_space

 def test_value_space(self):
     self.args = []
     preprocess_options(["--qu", "ux"], {"qu": (self._callback, True)})
     assert [("qu", "ux")] == self.args
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:4,代码来源:unittest_lint.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python lint.PyLinter类代码示例发布时间:2022-05-25
下一篇:
Python lint.fix_import_path函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap