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

Python option_helper.parse_args函数代码示例

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

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



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

示例1: test_jitarg_works

    def test_jitarg_works(self, cool_mod):
        # cannot actually check jit hint.
        argv = ['arg0'] + self.ok_jit_args + [cool_mod]
        config, names, args, retval = parse_args(argv)
        assert retval == RETURN_OK

        argv = ['arg0', cool_mod] + self.ok_jit_args
        config, names, args, retval = parse_args(argv)
        assert retval == RETURN_OK
开发者ID:pycket,项目名称:pycket,代码行数:9,代码来源:test_entry_point.py


示例2: test_jitarg_works

    def test_jitarg_works(self, empty_json):
        # cannot actually check jit hint.
        argv = ['arg0'] + self.ok_jit_args + [empty_json]
        config, names, args, retval = parse_args(argv)
        assert retval == 0

        argv = ['arg0', empty_json] + self.ok_jit_args
        config, names, args, retval = parse_args(argv)
        assert retval == 0
开发者ID:8l,项目名称:pycket,代码行数:9,代码来源:test_entry_point.py


示例3: test_verbose

    def test_verbose(self):
        config, names, args, retval = parse_args(['arg0', '--verbose'])
        assert config['verbose']
        assert names['verbosity_level'] == ['-1']

        config, names, args, retval = parse_args(['arg0', '--verbose', '2'])
        assert config['verbose']
        assert names['verbosity_level'] == ['2']
        assert retval == RETURN_OK
开发者ID:pycket,项目名称:pycket,代码行数:9,代码来源:test_entry_point.py


示例4: test_verbose_keywords

    def test_verbose_keywords(self):
        config, names, args, retval = parse_args(['arg0', '--verbose', 'regexp'])
        assert config['verbose']
        assert names['verbosity_level'] == ['-1']
        assert names['verbosity_keywords'] == ['regexp']

        config, names, args, retval = parse_args(['arg0', '--verbose', 'regexp', '--verbose', 'prims'])
        assert config['verbose']
        assert names['verbosity_level'] == ['-1']
        assert names['verbosity_keywords'] == ['regexp', 'prims']

        config, names, args, retval = parse_args(['arg0', '--verbose', 'regexp', '--verbose', '5', '--verbose', 'prims'])
        assert config['verbose']
        assert names['verbosity_level'] == ['5']
        assert names['verbosity_keywords'] == ['regexp', 'prims']
开发者ID:pycket,项目名称:pycket,代码行数:15,代码来源:test_entry_point.py


示例5: test_l

 def test_l(self, cool_mod):
     argv = ['arg0', "-l", cool_mod]
     config, names, args, retval = parse_args(argv)
     assert retval == RETURN_OK
     assert config['no-lib']
     assert 'loads' in names
     assert 'lib' in names['loads'] and cool_mod in names['load_arguments']
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例6: test_f

 def test_f(self, cool_mod):
     argv = ['arg0', "-f", cool_mod]
     config, names, args, retval = parse_args(argv)
     assert retval == RETURN_OK
     assert config == init_config
     assert 'loads' in names
     assert 'load' in names['loads'] and cool_mod in names['load_arguments']
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例7: actual_entry

    def actual_entry(argv):
        jit.set_param(None, "trace_limit", 1000000)
        jit.set_param(None, "threshold", 131)
        jit.set_param(None, "trace_eagerness", 50)

        if NonConstant(False):
            # Hack to give os.open() the correct annotation
            os.open("foo", 1, 1)

        config, names, args, retval = parse_args(argv)
        if retval != 0 or config is None:
            return retval
        args_w = [W_String.fromstr_utf8(arg) for arg in args]
        module_name, json_ast = ensure_json_ast(config, names)

        modtable = ModTable()
        modtable.enter_module(module_name)
        if json_ast is None:
            ast = expand_to_ast(module_name, modtable)
        else:
            ast = load_json_ast_rpython(json_ast, modtable)
        modtable.exit_module(module_name, ast)

        env = ToplevelEnv(pycketconfig)
        env.globalconfig.load(ast)
        env.commandline_arguments = args_w
        env.module_env.add_module(module_name, ast)
        try:
            val = interpret_module(ast, env)
        finally:
            from pycket.prims.input_output import shutdown

            shutdown(env)
        return 0
开发者ID:uternet,项目名称:pycket,代码行数:34,代码来源:entry_point.py


示例8: test_b

 def test_b(self):
     f_name = 'dummy.rkt'
     argv1 = ['arg0', "-b", f_name]
     config1, names1, args1, retval1 = parse_args(argv1)
     assert retval1 == 0
     assert names1['byte-expand'] == f_name
     assert args1 == []
开发者ID:magnusmorton,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例9: test_program_arguments_after_jit

 def test_program_arguments_after_jit(self, cool_mod):
     program_args = ["foo", "bar", "baz"]
     argv = ['arg0', cool_mod] + self.ok_jit_args + program_args
     config, names, args, retval = parse_args(argv)
     # again, must use "--"
     assert retval == MISSING_ARG
     assert args == []
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例10: actual_entry

    def actual_entry(argv):
        jit.set_param(None, "trace_limit", 1000000)
        jit.set_param(None, "threshold", 131)
        jit.set_param(None, "trace_eagerness", 50)

        config, names, args, retval = parse_args(argv)
        if retval != 0 or config is None:
            return retval
        args_w = [W_String.fromstr_utf8(arg) for arg in args]
        module_name, json_ast = ensure_json_ast(config, names)

        entry_flag = 'byte-expand' in names
        reader = JsonLoader(bytecode_expand=entry_flag)
        if json_ast is None:
            ast = reader.expand_to_ast(module_name)
        else:
            ast = reader.load_json_ast_rpython(module_name, json_ast)

        env = ToplevelEnv(pycketconfig)
        env.globalconfig.load(ast)
        env.commandline_arguments = args_w
        env.module_env.add_module(module_name, ast)
        try:
            val = interpret_module(ast, env)
        finally:
            from pycket.prims.input_output import shutdown
            if config.get('save-callgraph', False):
                with open('callgraph.dot', 'w') as outfile:
                    env.callgraph.write_dot_file(outfile)
            shutdown(env)
        return 0
开发者ID:rjnw,项目名称:pycket,代码行数:31,代码来源:entry_point.py


示例11: test_program_arguments_explicit

    def test_program_arguments_explicit(self, cool_mod):
        program_args = ["foo", "bar", "baz"]
        argv = ['arg0', cool_mod] + ["--"] + program_args
        config, names, args, retval = parse_args(argv)

        assert retval == RETURN_OK
        assert args == program_args
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例12: test_program_arguments_plain

 def test_program_arguments_plain(self, cool_mod):
     program_args = ["foo", "bar", "baz"]
     argv = ['arg0', cool_mod] + program_args
     config, names, args, retval = parse_args(argv)
     # must use "--"
     assert retval == MISSING_ARG
     assert args == []
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例13: test_program_arguments_explicit_with_switch

    def test_program_arguments_explicit_with_switch(self, empty_json):
        program_args = ["--jit", "foo", "bar", "baz"]
        argv = ['arg0', empty_json] + ["--"] + program_args
        config, names, args, retval = parse_args(argv)

        assert retval == 0
        assert args == program_args
开发者ID:8l,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例14: test_program_arguments_after_jit

    def test_program_arguments_after_jit(self, empty_json):
        program_args = ["foo", "bar", "baz"]
        argv = ['arg0', empty_json] + self.ok_jit_args + program_args
        config, names, args, retval = parse_args(argv)

        assert retval == 0
        assert args == program_args
开发者ID:8l,项目名称:pycket,代码行数:7,代码来源:test_entry_point.py


示例15: test_e

 def test_e(self):
     code = "(ratatta)"
     argv = ['arg0', "-e", code]
     config, names, args, retval = parse_args(argv)
     assert config == init_config
     assert retval == RETURN_OK
     assert 'loads' in names
     assert 'eval' in names['loads'] and code in names['load_arguments']
开发者ID:pycket,项目名称:pycket,代码行数:8,代码来源:test_entry_point.py


示例16: test_p

 def test_p(self, empty_json):
     argv = ['arg0', "-p", empty_json]
     config, names, args, retval = parse_args(argv)
     assert retval == 0
     assert names['file'] == empty_json + ".p"
     assert config['mode'] == option_helper._eval
     assert names['exprs'] == '(require (planet "%s"))' % empty_json
     assert args == []
开发者ID:8l,项目名称:pycket,代码行数:8,代码来源:test_entry_point.py


示例17: test_eval

 def test_eval(self):
     code = "(ratatta)"
     argv = ['arg0', "-e", code]
     config, names, args, retval = parse_args(argv)
     assert retval == 0
     assert 'file' not in names
     assert config['mode'] == option_helper._eval
     assert names['exprs'] == code
开发者ID:8l,项目名称:pycket,代码行数:8,代码来源:test_entry_point.py


示例18: test_f

 def test_f(self, empty_json):
     pytest.skip("re-enable when -f works again")
     argv = ['arg0', "-f", empty_json]
     config, names, args, retval = parse_args(argv)
     assert retval == 0
     assert names['file'] == empty_json+".f"
     assert config['mode'] == option_helper._eval
     assert names['exprs'] == '(load "%s")' % empty_json
     assert args == []
开发者ID:8l,项目名称:pycket,代码行数:9,代码来源:test_entry_point.py


示例19: actual_entry

def actual_entry(argv):
    jit.set_param(None, "trace_limit", 20000)

    config, names, args, retval = parse_args(argv)
    if retval != 0 or config is None:
        return retval
    args_w = [W_String(arg) for arg in args]
    module_name, json_ast = ensure_json_ast(config, names)
    if json_ast is None:
        ast = expand_to_ast(module_name) 
    else:
        ast = load_json_ast_rpython(json_ast)
    GlobalConfig.load(ast)
    env = ToplevelEnv()
    env.commandline_arguments = args_w
    env.module_env.add_module(module_name, ast)
    val = interpret_module(ast, env)
    return 0
开发者ID:antongulenko,项目名称:pycket,代码行数:18,代码来源:entry_point.py


示例20: actual_entry

    def actual_entry(argv):
        jit.set_param(None, "trace_limit", 1000000)

        config, names, args, retval = parse_args(argv)
        if retval != 0 or config is None:
            return retval
        args_w = [W_String.fromstr_utf8(arg) for arg in args]
        module_name, json_ast = ensure_json_ast(config, names)
        modtable = ModTable()
        if json_ast is None:
            ast = expand_to_ast(module_name, modtable)
        else:
            ast = load_json_ast_rpython(json_ast, modtable)
        env = ToplevelEnv(pycketconfig)
        env.globalconfig.load(ast)
        env.commandline_arguments = args_w
        env.module_env.add_module(module_name, ast)
        try:
            val = interpret_module(ast, env)
        finally:
            from pycket.prims.input_output import shutdown
            shutdown(env)
        return 0
开发者ID:rrnewton,项目名称:pycket,代码行数:23,代码来源:entry_point.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python expose.default函数代码示例发布时间:2022-05-25
下一篇:
Python interpreter.return_value函数代码示例发布时间: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