def generate_source_types_subparsers(self):
        build_subparsers = self.build_parser.add_subparsers(help='select source provider to use',
                                                            dest='source__provider')
        self.source_types_parsers = {
            'git': build_subparsers.add_parser(
                'git',
                help='build from a git repo',
                usage="%s [OPTIONS] build git" % PROG),
            'path': build_subparsers.add_parser(
                'path',
                help='build from a local path',
                usage="%s [OPTIONS] build path" % PROG),
        }
        source_types_uri_help = {
            'git': 'URI of the git repo',
            'path': 'URI of the directory with source (e.g. "file:///foo/bar") or\
                    path (e.g. "/foo/bar"); path can be relative',
        }
        source_types_df_path_help = {
            'git': 'path to Dockerfile within git repo (default is ./)',
            'path': 'path to Dockerfile within given directory (default is ./)',
        }

        # add arguments that are common to non-json source types
        for st, stp in self.source_types_parsers.items():
            stp.add_argument(
                "--image", action='store', required=True,
                help="name under which the image will be accessible")
            stp.add_argument(
                "--uri", action='store', metavar="URI", required=True,
                help=source_types_uri_help[st], dest='source__uri')
            stp.add_argument(
                "--df-path", action='store', help=source_types_df_path_help[st],
                dest='source__dockerfile_path')
            stp.add_argument(
                "--source-registry", action='store', metavar="REGISTRY",
                help="registry to pull base image from")
            stp.add_argument(
                "--source-registry-insecure", action='store_true',
                help="allow connecting to source registry over plain http")
            stp.add_argument(
                "--target-registries", action='store', nargs="*", metavar="REGISTRY",
                help="list of registries to push image to")
            stp.add_argument(
                "--target-registries-insecure", action='store_true',
                help="allow connecting to target registries over plain http")
            stp.add_argument(
                "--dont-pull-base-image", action='store_true',
                help="don't pull or update base image specified in dockerfile")

        # add the "json" subparser that allows to build from a json build file
        self.source_types_parsers['json'] = build_subparsers.add_parser(
            'json',
            help='load build configuration from json file',
            usage="%s [OPTIONS] build json" % PROG)

        # add arguments common to both non-json and json source types
        for stp in self.source_types_parsers.values():
            stp.add_argument(
                "--build-image", action='store',
                help="name of build image to use (build image type has to match method)")
            stp.add_argument(
                "--load-plugin", action="store", nargs="*", metavar="PLUGIN_FILE",
                dest="plugin_files", help="list of files where plugins live")
            stp.add_argument(
                "--method", action='store', required=True,
                choices=["hostdocker", "privileged", "here"],
                help="choose method for building image: "
                     "'hostdocker' mounts socket inside privileged container to use docker from host, "
                     "'privileged' runs separate docker instance inside privileged container "
                     "and 'here' executes build in current environment")

        # add sourcetype-specific arguments now
        self.source_types_parsers['git'].add_argument(
            '--commit', action='store',
            dest='source__provider_params__git_commit',
            help="checkout this commit (default is master)")
        self.source_types_parsers['json'].add_argument(
            'json_path', metavar='JSON_PATH',
            help='path to the build json')
        self.source_types_parsers['json'].add_argument(
            '--substitute', nargs='*', metavar='SUBSTITUTE',
            help='provide substitutions for json in form "foo.bar=spam"')
dataset/ETHPy150Open projectatomic/atomic-reactor/atomic_reactor/cli/main.py/CLI.generate_source_types_subparsers/original