Ejemplo n.º 1
0
 def add_argument_group(self, *args, **kwargs):
     group = argparse._ArgumentGroup(self, *args, **kwargs)
     self._action_groups.append(group)
     group.add_enzyme = self.add_enzyme
     group.add_fasta = self.add_fasta
     group.add_out = self.add_out
     group.add_vcf = self.add_vcf
     return group
Ejemplo n.º 2
0
 def add_argument_group(self, *args, **kwargs):
     group = argparse._ArgumentGroup(self, *args, **kwargs)
     self._action_groups.append(group)
     group.add_enzyme = self.add_enzyme
     group.add_fasta = self.add_fasta
     group.add_out = self.add_out
     group.add_vcf = self.add_vcf
     return group
Ejemplo n.º 3
0
def split_subparser_argument(parent, original, name, condition):
    new_sub_parser = argparse._SubParsersAction(original.option_strings,
                                                original._prog_prefix,
                                                original._parser_class,
                                                metavar=original.metavar)
    new_sub_parser._name_parser_map = original._name_parser_map
    new_sub_parser._choices_actions = [
        a for a in original._choices_actions
        if condition(original._name_parser_map[a.dest])
    ]
    group = argparse._ArgumentGroup(parent, name)
    group._group_actions = [new_sub_parser]
    return group
Ejemplo n.º 4
0
        def add_subcommand_group(title, commands):
            """Add informational help group for a specific subcommand set."""
            cmd_set = set(c for c in commands)

            # make a dict of commands of interest
            cmds = dict((a.dest, a) for a in self.actions if a.dest in cmd_set)

            # add commands to a group in order, and add the group
            group = argparse._ArgumentGroup(self, title=title)
            for name in commands:
                group._add_action(cmds[name])
                if name in remaining:
                    remaining.remove(name)
            add_group(group)
Ejemplo n.º 5
0
        def add_subcommand_group(title, commands):
            """Add informational help group for a specific subcommand set."""
            cmd_set = set(c for c in commands)

            # make a dict of commands of interest
            cmds = dict((a.metavar, a) for a in self.actions
                        if a.metavar in cmd_set)

            # add commands to a group in order, and add the group
            group = argparse._ArgumentGroup(self, title=title)
            for name in commands:
                group._add_action(cmds[name])
                if name in remaining:
                    remaining.remove(name)
            add_group(group)
Ejemplo n.º 6
0
    def __init__(self):
        super().__init__(usage="%s [GLOBAL OPTIONS] [COMMAND] [COMMAND ARGUMENTS] " \
                               "[COMMAND OPTIONS]" % versioning.__shortname__, \
                         description="iLOrest is a command-line interface that allows you " \
                                     "to manage Hewlett Packard Enterprise products that take advantage" \
                                     " of RESTful APIs.\n\nIn order to view or manage a system you must" \
                                     " first login. You can login using the login command or during " \
                                     "execution of any other command.\nFrom here you can run any other " \
                                     "commands. To learn more about specific commands, run iLOrest " \
                                     "COMMAND -h.\nA list of commands with descriptions is available at" \
                                     " the end of this help.", \
                         epilog="Examples:\n\nThe following is the standard flow of command" \
                                "s to view system data.\n\tThe first example is each command " \
                                "run individually: \n\n\tilorest login\n\tilorest select Bios.\n\t" \
                                "ilorest get\n\n\tThe second is the list of all of the commands " \
                                "run at once. First locally, then remotely.\n\tilorest get " \
                                "--select Bios.\n\tilorest get --select Bios. --url <iLO IP> -u" \
                                " <iLO Username> -p <iLO Password>", \
                         formatter_class=RawDescriptionHelpFormatter)
        globalgroup = _ArgumentGroup(self, "GLOBAL OPTIONS")

        self.add_argument('-c', \
                          '--config', \
                          dest='config', \
                          help="Use the provided configuration file instead of the default one.", \
                          metavar='FILE')

        config_dir_default = os.path.join(cliutils.get_user_config_dir(), \
                                          '.%s' % versioning.__shortname__)
        self.add_argument(
            '--cache-dir', \
            dest='config_dir', \
            default=config_dir_default, \
            help="Use the provided directory as the location to cache data" \
                 " (default location: %s)" % config_dir_default, \
            metavar='PATH')
        self.add_argument(
            '-v', \
            '--verbose', \
            dest='verbose', \
            #nargs='*',
            #action=_Verbosity,


            action="count",\
            help="Display verbose information (with increasing level). \'-v\': Level 1, " \
                 "Logging, Stdout, Stderr. \'-vv\': Level 2, Extends Level 1 with slightly " \
                 "elaborated iLO and HTTP response message. '-vvv': Level3, Extends Level 2 " \
                 "with message id, validation class, message text with embedded args, and " \
                 "possible resolution/mitigation for iLO responses. High detailed HTTP responses. " \
                 "**NOTE 1**: Some responses may only contain limited information from the source." \
                 "**NOTE 4**: Default level is 0.", \
            default=0)
        self.add_argument(
            '-d', \
            '--debug', \
            dest='debug', \
            action="store_true", \
            help="""Display debug information.""", \
            default=False)
        self.add_argument(
            '--logdir', \
            dest='logdir', \
            default=None, \
            help="""Use the provided directory as the location for log file.""", \
            metavar='PATH')
        self.add_argument(
            '--nocache', \
            dest='nocache', \
            action="store_true", \
            help="During execution the application will temporarily store data only in memory.", \
            default=False)
        self.add_argument(
            '--nologo', \
            dest='nologo', \
            action="store_true", \
            help="""Include to block copyright and logo.""", \
            default=False)
        self.add_argument(
            '--notoolbar', \
            dest='notoolbar', \
            action="store_true", \
            help="""Block toolbar at the bottom.""", \
            default=False)
        self.add_argument(
            '--redfish', \
            dest='is_redfish', \
            action='store_true', \
            help="Use this flag if you wish to to enable " \
                 "Redfish only compliance. It is enabled by default " \
                 "in systems with iLO5 and above.", \
            default=False)
        self.add_argument(
            '--latestschema', \
            dest='latestschema', \
            action='store_true', \
            help="Optionally use the latest schema instead of the one " \
                 "requested by the file. Note: May cause errors in some data " \
                 "retrieval due to difference in schema versions.", \
            default=False)
        self.add_argument(
            '--proxy', \
            dest='proxy', \
            default=None, \
            help="""Use the provided proxy for communication.""", \
            metavar='URL')
        self.add_argument(
            '--redirectconsole', \
            dest='redirect', \
            help="Optionally include this flag to redirect stdout/stderr console.", \
            nargs='?', \
            default=None, \
            const=True, \
            metavar='REDIRECT CONSOLE')
        self.add_argument_group(globalgroup)
    2. Default name, Specified directory
       --genes  --output '/my/path'

          => '/my/path/gene.loci'

    3. Specified path
       --genes 'genes.intervals' --output  '/my/path'

          => 'genes.intervals'

________________________________________________________________________

""",
    )

    standard_options = argparse._ArgumentGroup(parser, "Standard arguments")
    parser._action_groups.insert(0, standard_options)

    standard_options.add_argument(
        "-i",
        "--index",
        metavar="PATH",
        default=os.path.join(exe_path, "gtf.index"),
        help="PATH to the index of all gtf files.",
    )
    standard_options.add_argument(
        "--print_species", action="store_true", help="Print list of indexed species and exit."
    )

    standard_options.add_argument(
        "-s",
Ejemplo n.º 8
0
    def __init__(self):
        super(RdmcOptionParser, self).__init__("Usage: %s [GLOBAL OPTIONS] [COMMAND] [ARGUMENTS]" \
                                                "[COMMAND OPTIONS]" % versioning.__shortname__)

        globalgroup = _ArgumentGroup(self, "GLOBAL OPTIONS")

        self.add_argument('-c',
                          '--config',
                          dest='config',
                          help="Use the provided configuration file instead of the default one.",
                          metavar='FILE')

        config_dir_default = os.path.join(cliutils.get_user_config_dir(),\
                                            '.%s' % versioning.__shortname__)
        self.add_argument(
            '--cache-dir',
            dest='config_dir',
            default=config_dir_default,
            help="Use the provided directory as the location to cache data"\
            " (default location: %s)" % config_dir_default,
            metavar='PATH')
        self.add_argument(
            '-v',
            '--verbose',
            dest='verbose',
            action="store_true",
            help="""Display verbose information.""",
            default=False)
        self.add_argument(
            '-d',
            '--debug',
            dest='debug',
            action="store_true",
            help="""Display debug information.""",
            default=False)
        self.add_argument(
            '--logdir',
            dest='logdir',
            default=None,
            help="""Use the provided directory as the location for log file.""",
            metavar='PATH')
        self.add_argument(
            '--nocache',
            dest='nocache',
            action="store_true",
            help="During execution the application will temporarily store data only in memory.",
            default=False)
        self.add_argument(
            '--nologo',
            dest='nologo',
            action="store_true",
            help="""Include to block copyright and logo.""",
            default=False)
        self.add_argument(
            '--redfish',
            dest='is_redfish',
            action='store_true',
            help="Use this flag if you wish to to enable "\
                "Redfish only compliance. It is enabled by default "\
                "in systems with iLO5 and above.",
            default=False)
        self.add_argument(
            '--latestschema',
            dest='latestschema',
            action='store_true',
            help="Optionally use the latest schema instead of the one "\
            "requested by the file. Note: May cause errors in some data "\
            "retrieval due to difference in schema versions.",
            default=False)
        self.add_argument(
            '--proxy',
            dest='proxy',
            default=None,
            help="""Use the provided proxy for communication.""",
            metavar='URL')
        self.add_argument_group(globalgroup)
Ejemplo n.º 9
0
    2. Default name, Specified directory
       --genes  --output '/my/path'

          => '/my/path/gene.loci'

    3. Specified path
       --genes 'genes.intervals' --output  '/my/path'

          => 'genes.intervals'

________________________________________________________________________

""")

    standard_options = argparse._ArgumentGroup(parser, 'Standard arguments')
    parser._action_groups.insert(0, standard_options)

    standard_options.add_argument("-i",
                                  "--index",
                                  metavar="PATH",
                                  default=os.path.join(exe_path, "gtf.index"),
                                  help="PATH to the index of all gtf files.")
    standard_options.add_argument(
        "--print_species",
        action="store_true",
        help="Print list of indexed species and exit.")

    standard_options.add_argument("-s",
                                  "--species",
                                  metavar="NAME",
Ejemplo n.º 10
0
    def __init__(self):
        super(RdmcOptionParser, self).__init__(usage="%s [GLOBAL OPTIONS] [COMMAND] " \
                                "[COMMAND ARGUMENTS] [COMMAND OPTIONS]" % versioning.__shortname__,
                                description="iLOrest is a command-line interface that allows you "\
                                "to manage Hewlett Packard Enterprise products that take advantage"\
                                " of RESTful APIs.\n\nIn order to view or manage a system you must"\
                                " first login. You can login using the login command or during "\
                                "execution of any other command.\nFrom here you can run any other "\
                                "commands. To learn more about specific commands, run iLOrest "\
                                "COMMAND -h.\nA list of commands with descriptions is available at"\
                                " the end of this help.",
                                epilog="Examples:\n\nThe following is the standard flow of command"\
                                "s to view system data.\n\tThe first example is each command "\
                                "run individually: \n\n\tilorest login\n\tilorest select Bios.\n\t"\
                                "ilorest get\n\n\tThe second is the list of all of the commands "\
                                "run at once. First locally, then remotely.\n\tilorest get "\
                                "--select Bios.\n\tilorest get --select Bios. --url <iLO IP> -u"\
                                " <iLO Username> -p <iLO Password>",\
                                formatter_class=RawDescriptionHelpFormatter)
        globalgroup = _ArgumentGroup(self, "GLOBAL OPTIONS")

        self.add_argument(
            '-c',
            '--config',
            dest='config',
            help=
            "Use the provided configuration file instead of the default one.",
            metavar='FILE')

        config_dir_default = os.path.join(cliutils.get_user_config_dir(),\
                                            '.%s' % versioning.__shortname__)
        self.add_argument(
            '--cache-dir',
            dest='config_dir',
            default=config_dir_default,
            help="Use the provided directory as the location to cache data"\
            " (default location: %s)" % config_dir_default,
            metavar='PATH')
        self.add_argument(
            '-v',
            '--verbose',
            dest='verbose',
            action="count",
            help="""Display verbose information (with increasing level).\n\t\'-v\': Level 1""" \
                 """\n\t\'-vv\': Level 2""")
        self.add_argument('-d',
                          '--debug',
                          dest='debug',
                          action="store_true",
                          help="""Display debug information.""",
                          default=False)
        self.add_argument(
            '--logdir',
            dest='logdir',
            default=None,
            help="""Use the provided directory as the location for log file.""",
            metavar='PATH')
        self.add_argument(
            '--nocache',
            dest='nocache',
            action="store_true",
            help=
            "During execution the application will temporarily store data only in memory.",
            default=False)
        self.add_argument('--nologo',
                          dest='nologo',
                          action="store_true",
                          help="""Include to block copyright and logo.""",
                          default=False)
        self.add_argument(
            '--redfish',
            dest='is_redfish',
            action='store_true',
            help="Use this flag if you wish to to enable "\
                "Redfish only compliance. It is enabled by default "\
                "in systems with iLO5 and above.",
            default=False)
        self.add_argument(
            '--latestschema',
            dest='latestschema',
            action='store_true',
            help="Optionally use the latest schema instead of the one "\
            "requested by the file. Note: May cause errors in some data "\
            "retrieval due to difference in schema versions.",
            default=False)
        self.add_argument('--proxy',
                          dest='proxy',
                          default=None,
                          help="""Use the provided proxy for communication.""",
                          metavar='URL')
        self.add_argument(
            '--quiet',
            '--silent',
            dest='silent',
            help=
            "Optionally include this flag to redirect console print statements.",
            #action=_SilentAction,
            #type=str,
            nargs='?',
            default=None,
            const=True,
            metavar='Silent')
        self.add_argument_group(globalgroup)