Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(11)  |  Call(11)  |  Derive(0)  |  Import(0)
Parse and group arguments

        def parse_args(args_in):
    """Parse and group arguments"""
    parser = argparse.ArgumentParser(prog="Xnt")
    parser.add_argument("-v", "--verbose",
                        help="be verbose",
                        action="store_true",
                        dest="verbose")
    parser.add_argument(
        "--version",
        action="version",
        version=xnt.__version__,
        help="print the version information and quit")
    parser.add_argument(
        "-b", "--build-file",
        dest="build-file",
        help="use the given buildfile")
    parser.add_argument("-l", "--list-targets",
                        action="store_true",
                        dest="list-targets",
                        help="print build targets")
    # Properties Group
    params_group = parser.add_argument_group("Properties")
    params_group.add_argument(
        "-D", dest="properties", action="append",
        help="use value for gvien property")
    target_group = parser.add_argument_group("Targets")

    # Targets Group
    target_group.add_argument("targets", nargs=argparse.REMAINDER,
                              help="name(s) of targets to invoke")
    return vars(parser.parse_args(args_in))
        


src/x/n/Xnt-0.6.3/xnt/tests/xenantargparsertests.py   Xnt(Download)
    def test_nil_args(self):
        """Test the empty case (no arguements)"""
        args_in = []
        args = xnt.xenant.parse_args(args_in)
        self.assertIsNotNone(args)
    def test_single_target(self):
        """Test the single target case"""
        args_in = ["my_target"]
        args = xnt.xenant.parse_args(args_in)
        self.assertIsNotNone(args)
    def test_verbose(self):
        """Test verbose flag"""
        args_in = ["-v"]
        args = xnt.xenant.parse_args(args_in)
        self.assertIsNotNone(args)
    def test_list_targets_short(self):
        """Test list targets flag, short hand"""
        args_in = ["-l"]
        args = xnt.xenant.parse_args(args_in)
        self.assertIsNotNone(args)
    def test_list_targets_long(self):
        """Test list targets flag, long hand"""
        args_in = ["--list-targets"]
        args = xnt.xenant.parse_args(args_in)
        self.assertIsNotNone(args)