How to use ConfigArgParse - 10 common examples

To help you get started, we’ve selected a few ConfigArgParse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-services / autopush-loadtester / aplt / runner.py View on Github external
def parse_scenario_args(args):
    parser = ArgumentParser(
        description="Run a scenario",
        default_config_files=["config.ini"],
        args_for_setting_config_path=["-c", "--config"],
    )
    parse_common_args(parser)
    parser.add_argument("scenario")
    parser.add_argument("scenario_args", nargs="*",
                        help="Arguments for the specific scenario")
    return parser.parse_args(args)
github Zomojo / compiletools / ct / test_headerdeps.py View on Github external
if extraargs is None:
        extraargs = []
    temp_config_name = ct.unittesthelper.create_temp_config(tempdir)

    argv = [
        "--headerdeps",
        name,
        "--include",
        uth.ctdir(),
        "-c",
        temp_config_name,
    ] + extraargs
    cachename = os.path.join(tempdir, name)
    _reload_ct(cachename)

    cap = configargparse.getArgumentParser()
    ct.headerdeps.add_arguments(cap)
    args = ct.apptools.parseargs(cap, argv)
    headerdeps = ct.headerdeps.create(args)

    return cachename, temp_config_name, _callprocess(headerdeps, realpaths)
github Zomojo / compiletools / ct / test_namer.py View on Github external
def test_executable_pathname(self):
        config_dir = os.path.join(uth.cakedir(), "ct.conf.d")
        config_files = [os.path.join(config_dir, "gcc.debug.conf")]
        cap = configargparse.getArgumentParser(
            description="TestNamer",
            formatter_class=configargparse.ArgumentDefaultsHelpFormatter,
            default_config_files=config_files,
            args_for_setting_config_path=["-c", "--config"],
            ignore_unknown_config_file_keys=True,
        )
        argv = ["--no-git-root"]
        ct.apptools.add_common_arguments(cap=cap, argv=argv, variant="gcc.debug")
        ct.namer.Namer.add_arguments(cap=cap, argv=argv, variant="gcc.debug")
        args = ct.apptools.parseargs(cap, argv)
        namer = ct.namer.Namer(args, argv=argv, variant="gcc.debug")
        exename = namer.executable_pathname("/home/user/code/my.cpp")
        self.assertEqual(exename, "bin/gcc.debug/my")
github Zomojo / compiletools / ct / test_hunter.py View on Github external
def test_hunter_follows_source_files_from_header(self):
        origcache = ct.dirnamer.user_cache_dir("ct")
        tempdir = tempfile.mkdtemp()
        _reload_ct(tempdir)

        temp_config = ct.unittesthelper.create_temp_config()
        argv = ["-c", temp_config, "--include", uth.ctdir()]
        cap = configargparse.getArgumentParser()
        ct.hunter.add_arguments(cap)
        args = ct.apptools.parseargs(cap, argv)
        headerdeps = ct.headerdeps.create(args)
        magicparser = ct.magicflags.create(args, headerdeps)
        hntr = ct.hunter.Hunter(args, headerdeps, magicparser)

        relativepath = "factory/widget_factory.hpp"
        realpath = os.path.join(uth.samplesdir(), relativepath)
        filesfromheader = hntr.required_source_files(realpath)
        filesfromsource = hntr.required_source_files(ct.utils.implied_source(realpath))
        self.assertSetEqual(filesfromheader, filesfromsource)

        # Cleanup
        os.unlink(temp_config)
        shutil.rmtree(tempdir)
        _reload_ct(origcache)
github bw2 / ConfigArgParse / tests / test_configargparse.py View on Github external
def testGlobalInstances(self, name=None):
        p = configargparse.getArgumentParser(name, prog="prog", usage="test")
        self.assertEqual(p.usage, "test")
        self.assertEqual(p.prog, "prog")
        self.assertRaisesRegex(ValueError, "kwargs besides 'name' can only be "
            "passed in the first time", configargparse.getArgumentParser, name,
            prog="prog")

        p2 = configargparse.getArgumentParser(name)
        self.assertEqual(p, p2)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_with_files(self, application_parse):
        assert is_recursive_subnamespace(Namespace(application=Namespace(files=["img_1.mnc"]),
                                                   mbm=Namespace(lsq12=Namespace(max_pairs=20))),
                                         application_parse)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_with_files(self, application_parse):
        assert is_recursive_subnamespace(Namespace(application=Namespace(files=["img_1.mnc"]),
                                                   mbm=Namespace(lsq12=Namespace(max_pairs=20))),
                                         application_parse)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_deeper_nesting(self, four_mbm_parse):
        assert is_recursive_subnamespace(Namespace(first_two=Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=22)),
                                                                       mbm2=Namespace(lsq12=Namespace(max_pairs=23))),
                                                   last_two=Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=24)),
                                                                      mbm2=Namespace(lsq12=Namespace(max_pairs=25)))),
                                         four_mbm_parse)
    def test_with_files(self, application_parse):
github SkygearIO / py-skygear / skygear / asset / test_cloud.py View on Github external
def mock_options(self, public=False):
        return Namespace(
            appname='skygear-test',
            cloud_asset_host='http://mock-cloud-asset.dev',
            cloud_asset_token='mock-cloud-asset-token',
            cloud_asset_public_prefix='http://mock-cloud-asset.dev/public',
            cloud_asset_private_prefix='http://mock-cloud-asset.dev/private',
            asset_store_public=public)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_nested_parsing(self, two_mbm_parse):
        assert is_recursive_subnamespace(Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=22)),
                                                   mbm2=Namespace(lsq12=Namespace(max_pairs=25))),
                                         two_mbm_parse)
    def test_deeper_nesting(self, four_mbm_parse):