我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用optparse.SUPPRESS_HELP。
def build_completion(opt_parser): commands = [] for group in opt_parser.option_groups: for option in group.option_list: long_option = option.get_opt_string().strip('-') complete_cmd = ['complete', '--command', 'youtube-dl', '--long-option', long_option] if option._short_opts: complete_cmd += ['--short-option', option._short_opts[0].strip('-')] if option.help != optparse.SUPPRESS_HELP: complete_cmd += ['--description', option.help] complete_cmd.extend(EXTRA_ARGS.get(long_option, [])) commands.append(shell_quote(complete_cmd)) with open(FISH_COMPLETION_TEMPLATE) as f: template = f.read() filled_template = template.replace('{{commands}}', '\n'.join(commands)) with open(FISH_COMPLETION_FILE, 'w') as f: f.write(filled_template)
def format_argument_help(self, formatter): """Function to help format argument help. :param formatter: formatter :type formatter: formatter """ if not self._args: return "" result = [] for option in self._args: if not option.help is optparse.SUPPRESS_HELP: output = formatter.format_option(option) output = self._repattern.sub(' ', output) result.append(output) return '%s\n' % "".join(result)
def fit_args(): """ This top-level function returns an opt parser in the event that this module is run from the command-line. """ parser = optparse.OptionParser() parser.add_option("-i", "--column-independent", dest="i_col", default=1, type="int", help="Column of independent variable for fit, 1-based count (default: %default)") parser.add_option("-d", "--column-dependent", dest="d_col", default=2, type="int", help="Column of dependent variable for fit, 1-based count (default: %default)") parser.add_option("-p", "--init-parameters", dest="init_parameters", default=None, help="Initial guess of model function parameters e.g. '[x0, alpha, beta, a0, y0]' (use single-quotes). If not given, initial values are calculated from input data (default: %default)") parser.add_option("-w", "--fitting-window", dest="window", default=None, help="Define a window of 0-1-scaled x values over which to fit the curve e.g. '[0.1,0.7]' (use single-quotes). If not given, entire input range is used (not recommended). (default: %default)") parser.add_option("-t", "--real-time", dest="real_time", default=False, action='store_true', help="Return output with time data in actual time [epoch seconds, instead of 0-1 scaled] (default: %default)") parser.add_option("-b", "--both-times", dest="both_times", action='store_true', help=optparse.SUPPRESS_HELP) return parser
def allow_external(): return Option( "--allow-external", dest="allow_external", action="append", default=[], metavar="PACKAGE", help=SUPPRESS_HELP, )
def allow_unsafe(): return Option( "--allow-unverified", "--allow-insecure", dest="allow_unverified", action="append", default=[], metavar="PACKAGE", help=SUPPRESS_HELP, ) # Remove after 7.0