Python optparse.OptionGroup() Examples
The following are 30
code examples of optparse.OptionGroup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
optparse
, or try the search function
.
Example #1
Source File: atrace_agent.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_options(parser): options = optparse.OptionGroup(parser, 'Atrace options') options.add_option('--atrace-categories', dest='atrace_categories', help='Select atrace categories with a comma-delimited ' 'list, e.g. --atrace-categories=cat1,cat2,cat3') options.add_option('-k', '--ktrace', dest='kfuncs', action='store', help='specify a comma-separated list of kernel functions ' 'to trace') options.add_option('--no-compress', dest='compress_trace_data', default=True, action='store_false', help='Tell the device not to send the trace data in ' 'compressed form.') options.add_option('-a', '--app', dest='app_name', default=None, type='string', action='store', help='enable application-level tracing for ' 'comma-separated list of app cmdlines') options.add_option('--from-file', dest='from_file', action='store', help='read the trace from a ' 'file (compressed) rather than running a ' 'live trace') return options
Example #2
Source File: config.py From linter-pylama with MIT License | 6 votes |
def add_option_group(self, group_name, _, options, provider): # add option group to the command line parser if group_name in self._mygroups: group = self._mygroups[group_name] else: group = optparse.OptionGroup(self.cmdline_parser, title=group_name.capitalize()) self.cmdline_parser.add_option_group(group) group.level = provider.level self._mygroups[group_name] = group # add section to the config file if group_name != "DEFAULT" and \ group_name not in self.cfgfile_parser._sections: self.cfgfile_parser.add_section(group_name) # add provider's specific options for opt, optdict in options: self.add_optik_option(provider, group, opt, optdict)
Example #3
Source File: basecommand.py From python-netsurv with MIT License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #4
Source File: basecommand.py From recruit with Apache License 2.0 | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #5
Source File: main.py From llvm-zorg with Apache License 2.0 | 6 votes |
def action_runserver(name, args): """run a llvmlab instance""" import llvmlab from optparse import OptionParser, OptionGroup parser = OptionParser("%%prog %s [options]" % name) parser.add_option("", "--reloader", dest="reloader", default=False, action="store_true", help="use WSGI reload monitor") parser.add_option("", "--debugger", dest="debugger", default=False, action="store_true", help="use WSGI debugger") parser.add_option("", "--profiler", dest="profiler", default=False, action="store_true", help="enable WSGI profiler") (opts, args) = parser.parse_args(args) if len(args) != 0: parser.error("invalid number of arguments") app = llvmlab.ui.app.App.create_standalone() if opts.debugger: app.debug = True if opts.profiler: app.wsgi_app = werkzeug.contrib.profiler.ProfilerMiddleware( app.wsgi_app, stream = open('profiler.log', 'w')) app.run(use_reloader = opts.reloader, use_debugger = opts.debugger)
Example #6
Source File: koji_pkgspec.py From avocado-vt with GNU General Public License v2.0 | 6 votes |
def __init__(self): optparse.OptionParser.__init__(self, usage=('Usage: %prog [options] ' '[koji-pkg-spec]')) general = optparse.OptionGroup(self, 'GENERAL OPTIONS') general.add_option('-a', '--arch', dest='arch', default='x86_64', help=('architecture of packages to list, together ' 'with "noarch". defaults to "x86_64"')) general.add_option('-t', '--tag', dest='tag', help='default koji tag') self.add_option_group(general) cartesian_config = optparse.OptionGroup(self, 'CARTESIAN CONFIG') cartesian_config.add_option('-c', '--config', dest='config', help=('use a cartesian configuration file ' 'for fetching package values')) self.add_option_group(cartesian_config)
Example #7
Source File: basecommand.py From jbox with MIT License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #8
Source File: config.py From python-netsurv with MIT License | 6 votes |
def add_option_group(self, group_name, _, options, provider): # add option group to the command line parser if group_name in self._mygroups: group = self._mygroups[group_name] else: group = optparse.OptionGroup( self.cmdline_parser, title=group_name.capitalize() ) self.cmdline_parser.add_option_group(group) group.level = provider.level self._mygroups[group_name] = group # add section to the config file if ( group_name != "DEFAULT" and group_name not in self.cfgfile_parser._sections ): self.cfgfile_parser.add_section(group_name) # add provider's specific options for opt, optdict in options: self.add_optik_option(provider, group, opt, optdict)
Example #9
Source File: config.py From python-netsurv with MIT License | 6 votes |
def add_option_group(self, group_name, _, options, provider): # add option group to the command line parser if group_name in self._mygroups: group = self._mygroups[group_name] else: group = optparse.OptionGroup( self.cmdline_parser, title=group_name.capitalize() ) self.cmdline_parser.add_option_group(group) group.level = provider.level self._mygroups[group_name] = group # add section to the config file if ( group_name != "DEFAULT" and group_name not in self.cfgfile_parser._sections ): self.cfgfile_parser.add_section(group_name) # add provider's specific options for opt, optdict in options: self.add_optik_option(provider, group, opt, optdict)
Example #10
Source File: basecommand.py From Python24 with MIT License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #11
Source File: basecommand.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #12
Source File: basecommand.py From vnpy_crypto with MIT License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #13
Source File: cmd_line.py From Yuki-Chan-The-Auto-Pentest with MIT License | 6 votes |
def getHachoirOptions(parser): """ Create an option group (type optparse.OptionGroup) of Hachoir library options. """ def setLogFilename(*args): log.setFilename(args[2]) common = OptionGroup(parser, _("Hachoir library"), \ "Configure Hachoir library") common.add_option("--verbose", help=_("Verbose mode"), default=False, action="store_true") common.add_option("--log", help=_("Write log in a file"), type="string", action="callback", callback=setLogFilename) common.add_option("--quiet", help=_("Quiet mode (don't display warning)"), default=False, action="store_true") common.add_option("--debug", help=_("Debug mode"), default=False, action="store_true") return common
Example #14
Source File: basecommand.py From FuYiSpider with Apache License 2.0 | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #15
Source File: basecommand.py From FuYiSpider with Apache License 2.0 | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #16
Source File: cmd_line.py From ITWSV with MIT License | 6 votes |
def getHachoirOptions(parser): """ Create an option group (type optparse.OptionGroup) of Hachoir library options. """ def setLogFilename(*args): log.setFilename(args[2]) common = OptionGroup(parser, _("Hachoir library"), \ "Configure Hachoir library") common.add_option("--verbose", help=_("Verbose mode"), default=False, action="store_true") common.add_option("--log", help=_("Write log in a file"), type="string", action="callback", callback=setLogFilename) common.add_option("--quiet", help=_("Quiet mode (don't display warning)"), default=False, action="store_true") common.add_option("--debug", help=_("Debug mode"), default=False, action="store_true") return common
Example #17
Source File: basecommand.py From oss-ftp with MIT License | 6 votes |
def __init__(self): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, self.parser) self.parser.add_option_group(gen_opts)
Example #18
Source File: base_command.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __init__(self, isolated=False): # type: (bool) -> None parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #19
Source File: base_command.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __init__(self, isolated=False): # type: (bool) -> None parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #20
Source File: basecommand.py From anpr with Creative Commons Attribution 4.0 International | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #21
Source File: basecommand.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #22
Source File: base_command.py From deepWordBug with Apache License 2.0 | 6 votes |
def __init__(self, isolated=False): # type: (bool) -> None parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #23
Source File: basecommand.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __init__(self, isolated=False): parser_kw = { 'usage': self.usage, 'prog': '%s %s' % (get_prog(), self.name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': self.name, 'description': self.__doc__, 'isolated': isolated, } self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group optgroup_name = '%s Options' % self.name.capitalize() self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options gen_opts = cmdoptions.make_option_group( cmdoptions.general_group, self.parser, ) self.parser.add_option_group(gen_opts)
Example #24
Source File: compat.py From tvalacarta with GNU General Public License v3.0 | 6 votes |
def workaround_optparse_bug9161(): op = optparse.OptionParser() og = optparse.OptionGroup(op, 'foo') try: og.add_option('-t') except TypeError: real_add_option = optparse.OptionGroup.add_option def _compat_add_option(self, *args, **kwargs): enc = lambda v: ( v.encode('ascii', 'replace') if isinstance(v, compat_str) else v) bargs = [enc(a) for a in args] bkwargs = dict( (k, enc(v)) for k, v in kwargs.items()) return real_add_option(self, *bargs, **bkwargs) optparse.OptionGroup.add_option = _compat_add_option
Example #25
Source File: atrace_process_dump.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_options(parser): options = optparse.OptionGroup(parser, 'Atrace process dump options') options.add_option('--process-dump', dest='process_dump_enable', default=False, action='store_true', help='Capture periodic per-process memory dumps.') options.add_option('--process-dump-interval', dest='process_dump_interval_ms', default=5000, help='Interval between memory dumps in milliseconds.') options.add_option('--process-dump-full', dest='process_dump_full_config', default=None, help='Capture full memory dumps for some processes.\n' \ 'Value: all, apps or comma-separated process names.') options.add_option('--process-dump-mmaps', dest='process_dump_mmaps', default=False, action='store_true', help='Capture VM regions and memory-mapped files.\n' \ 'It increases dump size dramatically, hence only ' \ 'has effect if --process-dump-full is a whitelist.') return options
Example #26
Source File: atrace_agent.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_options(parser): options = optparse.OptionGroup(parser, 'Atrace options') options.add_option('--atrace-categories', dest='atrace_categories', help='Select atrace categories with a comma-delimited ' 'list, e.g. --atrace-categories=cat1,cat2,cat3') options.add_option('-k', '--ktrace', dest='kfuncs', action='store', help='specify a comma-separated list of kernel functions ' 'to trace') options.add_option('--no-compress', dest='compress_trace_data', default=True, action='store_false', help='Tell the device not to send the trace data in ' 'compressed form.') options.add_option('-a', '--app', dest='app_name', default=None, type='string', action='store', help='enable application-level tracing for ' 'comma-separated list of app cmdlines') options.add_option('--from-file', dest='from_file', action='store', help='read the trace from a ' 'file (compressed) rather than running a ' 'live trace') return options
Example #27
Source File: atrace_process_dump.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_options(parser): options = optparse.OptionGroup(parser, 'Atrace process dump options') options.add_option('--process-dump', dest='process_dump_enable', default=False, action='store_true', help='Capture periodic per-process memory dumps.') options.add_option('--process-dump-interval', dest='process_dump_interval_ms', default=5000, help='Interval between memory dumps in milliseconds.') options.add_option('--process-dump-full', dest='process_dump_full_config', default=None, help='Capture full memory dumps for some processes.\n' \ 'Value: all, apps or comma-separated process names.') options.add_option('--process-dump-mmaps', dest='process_dump_mmaps', default=False, action='store_true', help='Capture VM regions and memory-mapped files.\n' \ 'It increases dump size dramatically, hence only ' \ 'has effect if --process-dump-full is a whitelist.') return options
Example #28
Source File: command_line_parser.py From sslyze with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, sslyze_version: str) -> None: """Generate SSLyze's command line parser. """ self._parser = OptionParser(version=sslyze_version, usage=self.SSLYZE_USAGE) # Add generic command line options to the parser self._add_default_options() # Add plugin .ie scan command options to the parser scan_commands_group = OptionGroup(self._parser, "Scan commands", "") for option in self._get_plugin_scan_commands(): scan_commands_group.add_option(f"--{option.option}", help=option.help, action=option.action) self._parser.add_option_group(scan_commands_group) # Add the --regular command line parameter as a shortcut if possible self._parser.add_option( "--regular", action="store_true", dest=None, help=f"Regular HTTPS scan; shortcut for --{'--'.join(self.REGULAR_CMD)}", )
Example #29
Source File: perf_tracing_agent.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_options(parser): options = optparse.OptionGroup(parser, 'Perf profiling options') options.add_option('-p', '--perf', help='Capture a perf profile with ' 'the chosen comma-delimited event categories. ' 'Samples CPU cycles by default. Use "list" to see ' 'the available sample types.', action='callback', default='', callback=_OptionalValueCallback('cycles'), metavar='PERF_CATEGORIES', dest='perf_categories') return options
Example #30
Source File: flags.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
def OutputOptions(parser): output_options = optparse.OptionGroup(parser, 'Output options') output_options.add_option('-o', '--output', dest='output_file', help='Save trace output to file.') output_options.add_option('--json', help='Save trace as raw JSON instead of ' 'HTML.', dest='write_json') output_options.add_option('--view', help='Open resulting trace file in a ' 'browser.', action='store_true') return output_options