def addSubcommand(self, cmd, usage=None): if usage == None: cmd.parser.usage = self.usage else: cmd.parser.usage = usage cmd.parser.formatter = TitledHelpFormatter() self.subcommands.append(cmd)
def main(): """Main test""" global USAGE parser = OptionParser(USAGE, formatter=TitledHelpFormatter(), version="tcsv2png %s" % get_version()) parser.add_option("-v", "--verbose", action="store_true", help="Verbose output") parser.add_option("-o", "--output", type="string", help="PNG output file") parser.add_option("-t", "--title", type="string", help="Chart title") parser.add_option("-b", "--bezier", action="store_true", help="Smooth bezier") parser.add_option("-c", "--csplines", action="store_true", help="Smooth csplines") options, args = parser.parse_args(sys.argv) if len(args) in [1, 3]: parser.error("Missing options") return if not options.output: options.output = os.path.splitext(args[1])[0] + ".png" if not options.title: options.title = args[1] try: cols = [int(col) for col in args[2:]] except ValueError: parser.error("ERROR: Expecting indices for column parameters " \ "Got: " + str(args[2:])) return script = GnuPlotScript(args[1], cols, options) script.process()
def parseArgs(self, argv): """Parse programs args.""" parser = OptionParser(self.USAGE, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("-v", "--verbose", action="store_true", help="Verbose output") parser.add_option("-p", "--port", type="string", dest="port", default=self.port, help="The proxy port.") parser.add_option("-i", "--tcp-watch-input", type="string", dest="tcpwatch_path", default=None, help="Path to an existing tcpwatch capture.") parser.add_option("-l", "--loop", type="int", dest="loop", default=1, help="Loop mode.") options, args = parser.parse_args(argv) if len(args) == 1: test_name = args[0] else: test_name = None self.verbose = options.verbose self.tcpwatch_path = options.tcpwatch_path self.port = options.port if not test_name and not self.tcpwatch_path: self.loop = options.loop if test_name: test_name = test_name.replace('-', '_') class_name = ''.join([x.capitalize() for x in re.split('_|-', test_name)]) self.test_name = test_name self.class_name = class_name self.script_path = './test_%s.py' % class_name self.configuration_path = './%s.conf' % class_name
def _create_parser(): parser = OptionParser(description='Deploy game from Local to the Hub', formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-i", "--input", action="store", dest="input", help="manifest file for the game to be deployed") parser.add_option("-u", "--user", action="store", dest="user", help="login username") parser.add_option("-p", "--password", action="store", dest="password", help="login password (will be requested if not provided)") parser.add_option("--project", action="store", dest="project", help="project to deploy to") parser.add_option("--projectversion", action="store", dest="projectversion", help="project version to deploy to") parser.add_option("--projectversiontitle", action="store", dest="projectversiontitle", help="project version title, for existing project versions this will overwrite the existing " \ "title if supplied. For new versions this defaults to the project version") parser.add_option("-c", "--cache", action="store", dest="cache", help="folder to be used for caching") parser.add_option("--hub", action="store", dest="hub", default=HUB_URL, help="Hub url (defaults to https://hub.turbulenz.com/)") parser.add_option("--ultra", action="store_true", dest="ultra", default=False, help="use maximum compression. Will take MUCH longer. May reduce file size by an extra 10%-20%.") return parser
def __init__(self, args, configFileLocations=None, usage=None, mandInt=None, mandStr=None): """ configFileLocations are full paths to the configuration files to use - first location which founds the file is taken, if the config file is not specified as a command line argument (config option). """ if not configFileLocations: configFileLocations = [] if not mandInt: mandInt = [] if not mandStr: mandStr = [] form = TitledHelpFormatter(width=78) self.parser = OptionParser(usage=usage, formatter=form, add_help_option=None) self.options = {} self.expertOptions = OptionGroup( self.parser, "Expert Options", "Caution: use these options at your own risk.") self.mandatoryInt = mandInt self.mandatoryStr = mandStr # implemented in the subclass - particular command line interface self.processCommandLineOptions(args) # self._options is now available - modify / add values according # to the values found in the config file self.processConfigFile(configFileLocations)
def format_option(self, option): old_help = option.help default = option.default if isinstance(default, str) and ' ' in default: default = repr(default) if option.help is None: option.help = 'Specify a %s.' % (option.type) if option.type == 'choice': choices = [] for choice in option.choices: if choice == option.default: if ' ' in choice: choice = repr(choice) choice = '[' + choice + ']' else: if ' ' in choice: choice = repr(choice) choices.append(choice) option.help = '%s Choices: %s.' % (option.help, ', '.join(choices)) else: if default != NO_DEFAULT: if option.action == 'store_false': option.help = '%s Default: %s.' % (option.help, not default) else: option.help = '%s Default: %s.' % (option.help, default) result = TitledHelpFormatter.format_option(self, option) option.help = old_help return result
def _parser(): usage = "usage: %prog [options] -i source.xml -o output.json" description = "Convert XML assets into a structured JSON asset." parser = OptionParser(description=description, usage=usage, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-m", "--metrics", action="store_true", dest="metrics", default=False, help="output asset metrics") parser.add_option("-i", "--input", action="store", dest="input", help="input XML file to process") parser.add_option("-o", "--output", action="store", dest="output", help="output JSON file to process") group = OptionGroup(parser, "Asset Generation Options") group.add_option("-j", "--json-indent", action="store", dest="json_indent", type="int", default=0, metavar="SIZE", help="json output pretty printing indent size, defaults to 0") group.add_option("-n", "--namespace", action="store_true", dest="namespace", default=False, help="maintain XML xmlns namespace in JSON asset keys.") group.add_option("-c", "--convert-types", action="store_true", dest="convert_types", default=False, help="attempt to convert values to ints, floats and lists.") parser.add_option_group(group) return parser
def _parser(): parser = OptionParser(description='Generate HTML files from .html and ' '.js files. Any options not recognised are ' 'assumed to be input files.', usage="usage: %prog [options] <input files>", formatter=TitledHelpFormatter()) default_parser_options(parser) parser.add_option("-C", "--code", action="store", dest="codefile", help="release file to be called by the HTML. Does not " "need to exist yet. (release and canvas modes only)") # Mode one of [ 'plugin', 'plugin-debug', 'canvas', 'canvas-debug' ] parser.add_option("-m", "--mode", action="store", dest="mode", default='plugin-debug', help="build mode: canvas, canvas-debug, plugin, " "plugin-debug (default)") parser.add_option("-D", "--dump-default-template", action="store_true", dest="dump_default_template", default=False, help="output the default template to file") return parser
def format_option(self, option): old_help = option.help default = option.default if isinstance(default, str) and " " in default: default = repr(default) if option.help is None: option.help = "Specify a %s." % (option.type) if option.type == "choice": choices = [] for choice in option.choices: if choice == option.default: if " " in choice: choice = repr(choice) choice = "[" + choice + "]" else: if " " in choice: choice = repr(choice) choices.append(choice) option.help = "%s Choices: %s." % (option.help, ", ".join(choices)) else: if default != NO_DEFAULT: if option.action == "store_false": option.help = "%s Default: %s." % (option.help, not default) else: option.help = "%s Default: %s." % (option.help, default) result = TitledHelpFormatter.format_option(self, option) option.help = old_help return result
def _parser(): usage = "usage: %prog [options] source.json [ ... ] target.json" description = 'Merge JSON asset files' parser = OptionParser(description=description, usage=usage, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-m", "--metrics", action="store_true", dest="metrics", default=False, help="output asset metrics") return parser
def format_option(self, option): old_help = option.help default = option.default if isinstance (default, str) and ' ' in default: default = repr (default) if option.help is None: option.help = 'Specify a %s.' % (option.type) if option.type=='choice': choices = [] for choice in option.choices: if choice==option.default: if ' ' in choice: choice = repr(choice) choice = '['+choice+']' else: if ' ' in choice: choice = repr(choice) choices.append (choice) option.help = '%s Choices: %s.'% (option.help, ', '.join(choices)) else: if default != NO_DEFAULT: if option.action=='store_false': option.help = '%s Default: %s.'% (option.help, not default) else: option.help = '%s Default: %s.'% (option.help, default) result = TitledHelpFormatter.format_option (self, option) option.help = old_help return result
def processCmdLine(args): def errExit(msg, parser): print('\n') parser.print_help() print("\n\n%s" % msg) sys.exit(1) form = TitledHelpFormatter(width=78) parser = OptionParser(usage="usage: %prog options", formatter=form, add_help_option=None) actions = defineCmdLineOptions(parser) # opts - new processed options # args - remainder of the input array opts, args = parser.parse_args(args=args) # check command line arguments validity if not opts.reqMgrUrl: errExit("Missing mandatory --reqMgrUrl.", parser) if opts.createRequest and not opts.configFile: errExit("When --createRequest, --configFile is necessary.", parser) if opts.changeSplitting and not opts.createRequest and not opts.configFile: errExit( "Without --createRequest, --configFile must be specified for --changeSplitting.", parser) if opts.changeSplitting and not opts.createRequest and not opts.requestNames: errExit( "Without --createRequest, --requestNames must be supplied to --changeSplitting.", parser) if opts.assignRequests and not opts.createRequest and not opts.configFile: errExit( "Without --createRequest, --configFile must be specified for --assignRequests.", parser) if opts.assignRequests and not opts.createRequest and not opts.requestNames: errExit( "Without --createRequest, --requestNames must be supplied to --assignRequests.", parser) if not opts.requestNames and (opts.queryRequests or opts.deleteRequests or \ (opts.assignRequests and not opts.createRequest) or \ (opts.changeSplitting and not opts.createRequest)): errExit("--requestNames must be supplied.", parser) if opts.createRequest and opts.requestNames: errExit("--requestNames can't be provided with --createRequest", parser) if opts.allTests and not opts.configFile: errExit("When --allTests, --configFile is necessary", parser) if (opts.json and not opts.createRequest) and (opts.json and not opts.allTests) \ and (opts.json and not opts.assignRequests) and (opts.json and not opts.changeSplitting): errExit( "--json only with --createRequest, --allTests, --assignRequest, --changeSplitting", parser) for action in filter(lambda name: getattr(opts, name), actions): if opts.allTests and action and action != "allTests": errExit( "Arguments --allTests and --%s mutually exclusive." % action, parser) if opts.requestNames: # make it a list here opts.requestNames = opts.requestNames.split(',') return opts, actions
def format_description(self, description): if description: return "".join([ TitledHelpFormatter.format_description(self, d) for d in description.split("\n\n") ]) else: return ""
def format_epilog(self, epilog): if epilog: return "\n" + ("-" * int(self.width / 2)) + "\n" + "".join([ TitledHelpFormatter.format_epilog(self, d) for d in epilog.split("\n\n") ]) else: return ""
def _parser(): parser = OptionParser(description='Convert a JavaScript file into a .tzjs' ' or .canvas.js file. Any options not recognised are' ' assumed to be input files.', usage="usage: %prog [options] <input files>", formatter=TitledHelpFormatter()) default_parser_options(parser) # Mode one of [ 'plugin', 'canvas' ] parser.add_option("-m", "--mode", action="store", dest="mode", default='plugin', help="build mode: canvas, " "plugin(default)") parser.add_option("--ignore-input-extension", action="store_true", dest="ignore_ext_check", default=False, help="allow input files with an extension other than .js") # Compacting parser.add_option("-y", "--yui", action="store", dest="yui", default=None, help="path to the YUI compressor, setting this enables " "compacting with the YUI compressor") parser.add_option("-c", "--closure", action="store", dest="closure", default=None, help="path to the Closure compiler, setting " "this enables the compacting with the Closure compiler " "(EXPERIMENTAL)") parser.add_option("-u", "--uglifyjs", action="store", dest="uglifyjs", default=None, help="path to the UglifyJS application, " "setting this enables the compacting with the UglifyJS " "compiler. This option assumes node.js is executable " "from the path.") parser.add_option("--uglify", action="store", dest="uglifyjs", default=None, help="Deprecated - Please use --uglifyjs") # Strip-debug parser.add_option("--no-strip-debug", action="store_false", dest="stripdebug", default=True, help="don't remove calls to debug.* methods") parser.add_option("--strip-debug", action="store", dest="stripdebugpath", default=None, help="set the path to the strip-debug application") parser.add_option("--strip-namespace", action="append", default=[], dest="stripnamespaces", help="add namespace to strip " "(see strip-debug --namespace flag)") parser.add_option("--strip-var", action="append", dest="stripvars", help="define a global bool var for static code stripping " "(see strip-debug -D flag)", default=[]) parser.add_option("--ignore-errors", action="store_true", dest="ignoreerrors", default=False, help="ignore any syntax errors found while parsing") # Line length parser.add_option("-l", "--line-break", action="store", type="int", dest="length", default=1000, help="split line length") return parser
def _parser(): usage = "usage: %prog [options] asset.json [ ... ]" description = """\ Report metrics on JSON asset files. Metrics are: "keys": number of bytes used by keys. "punctuation (punctn)": number of bytes used by JSON punctuation, including '[ ] { } " , :'. "values": number of bytes used by values. For uncompact JSON files this will also include the white space. "k%": percentage of total size used by the keys. "p%": percentage of total size used by the punctuation. "v%": percentage of total size used by the values (and white space). "# keys": the total number of keys. "unique": the number of unique keys. "total": the total asset size in byte. "gzip": the asset size after gzip compression. "ratio": the gzip size as a percentage of the uncompressed total size. """ epilog = 'This tool current assumes the JSON asset is compact with no additional white space.' parser = OptionParser(description=description, usage=usage, epilog=epilog, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-m", "--metrics", action="store_true", dest="metrics", default=False, help="output asset metrics") parser.add_option("-H", "--header", action="store_true", dest="header", default=False, help="generate column header") return parser
def _processCmdLineArgs(args): usage = \ """usage: %prog options""" form = TitledHelpFormatter(width=78) parser = OptionParser(usage=usage, formatter=form) _defineCmdLineOptions(parser) # opts - new processed options # args - remainder of the input array opts, args = parser.parse_args(args=args) return opts.couchUrl, opts.database, opts.number
def parseArgs(self, argv): """Parse programs args.""" parser = OptionParser(self.usage, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("-q", "--quiet", action="store_true", help="Suppress console output") parser.add_option("-v", "--verbose", action="store_true", help="Verbose mode (log-level debug)") options, args = parser.parse_args(argv) if len(args) != 3: parser.error("Missing argument") return args[1], args[2], options
def _parser(): parser = OptionParser( description= 'Generate a TAR file for binary assets referenced from a JSON asset.', usage='%prog -i input.json -o output.tar [options]', formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-i", "--input", action="store", dest="input", help="input file to process") parser.add_option("-o", "--output", action="store", dest="output", help="output file to process") parser.add_option("-a", "--assets", action="store", dest="asset_root", default=".", metavar="PATH", help="path of the asset root") parser.add_option("-M", action="store_true", dest="dependency", default=False, help="output dependencies") parser.add_option("--MF", action="store", dest="dependency_file", help="dependencies output to file") return parser
def parseArgs(self, argv): """Parse programs args.""" parser = OptionParser(self.usage, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("-v", "--verbose", action="store_true", help="Verbose output") parser.add_option("-d", "--debug", action="store_true", help="debug mode, server is run in forground") options, args = parser.parse_args(argv) if len(args) != 2: parser.error("Missing configuration file argument") return args[1], options
def test_help_title_formatter(self): self.parser.formatter = TitledHelpFormatter() self.assertHelpEquals("""\ Usage ===== bar.py [options] options ======= -aAPPLE throw APPLEs at basket --boo=NUM, -bNUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing --help, -h show this help message and exit """)
def __init__(self, args=None, usage=None, version=None, description=None, interspersed=False): """ @param usage: usage string. If missing a default is used @param version: if missing the PyFoam-version is used @param description: description of the utility @param interspersed: needs to be false if options should be passed to an OpenFOAM-utility @param args: Command line arguments. If unset sys.argv[1:] is used. Can be a string: it will be splitted then unsing the spaces (very primitive), or a list of strings (prefered) """ if usage == None: if oldApp(): usage = "%prog [options] <foamApplication> <caseDir> <caseName> [foamOptions]" else: usage = "%prog [options] <foamApplication> [foamOptions]" if version == None: version = "%prog " + versionString() if args == None: self.argLine = None elif type(args) == str: self.argLine = args.split() else: self.argLine = map(str, args) OptionParser.__init__( self, usage=usage, # prog=self.__type__.__name__, version=version, description=description, formatter=TitledHelpFormatter()) if interspersed: self.enable_interspersed_args() else: self.disable_interspersed_args() self.options = None self.args = None self.__foamVersionChanged = False self.__oldEnvironment = None
def readCommadLine(arguments, usage): """Read the command line - returns options""" parser = OptionParser(usage, version="%s" % VERSION, formatter=TitledHelpFormatter(width=255, indent_increment=4)) cfg = SafeConfigParser() buildParams(cfg, parser) options, args = parser.parse_args(arguments) for option in moptions: if getattr(options, option) is None: print "\nA mandatory option is missing\n" parser.print_help() sys.exit(1) return options
def _processCmdLineArgs(args): usage = \ """usage: %prog options""" form = TitledHelpFormatter(width = 78) parser = OptionParser(usage = usage, formatter = form, add_help_option = None) _defineCmdLineOptions(parser) # opts - new processed options # args - remainder of the input array opts, args = parser.parse_args(args = args) for mandatory in ("input", "couchUrl", "database"): if not getattr(opts, mandatory, None): logging.error("Missing mandatory option ('%s')." % mandatory) parser.print_help() sys.exit(1) return opts.input, opts.couchUrl, opts.database
def __init__(self, args, configFileLocations=[], usage=None): """ configFileLocations are full paths to the configuration files to use - first location which founds the file is taken, if the config file is not specified as a command line argument (config option). """ form = TitledHelpFormatter(width=78) self._parser = OptionParser(usage=usage, formatter=form, add_help_option=None) # implemented in the subclass - particular command line interface self.processCommandLineOptions(args) # self._options is now available - modify / add values according # to the values found in the config file self._processConfigFile(configFileLocations)
def process_cli_args(args): def err_exit(msg, parser): print('\n') parser.print_help() print("\n\n%s" % msg) sys.exit(1) form = TitledHelpFormatter(width=78) parser = OptionParser(usage="usage: %prog options", formatter=form, add_help_option=None) actions = define_cli_options(parser) # opts - new processed options # args - remainder of the input array opts, args = parser.parse_args(args=args) # check command line arguments validity if not opts.reqmgrurl: err_exit("Missing mandatory --reqmgrurl.", parser) if opts.create_request and not opts.config_file: err_exit("When --create_request, --config_file is necessary.", parser) if opts.create_request and opts.request_names: err_exit("--request_names can't be provided with --create_request", parser) if opts.all_tests and not opts.config_file: err_exit("When --all_tests, --config_file is necessary", parser) if opts.json and not (opts.create_request or opts.assign_request or opts.all_tests): err_exit( "--json only with --create_request, --assign_request or --all_tests", parser) for action in filter(lambda name: getattr(opts, name), actions): if opts.all_tests and action and action != "all_tests": err_exit( "Arguments --all_tests and --%s mutually exclusive." % action, parser) if opts.request_names: # make it a list here opts.request_names = opts.request_names.split(',') return opts, actions
def _processCmdLineArgs(args): def errExit(parser): logging.error("Missing mandatory option, see help.") parser.print_help() sys.exit(1) usage = \ """usage: %prog options""" form = TitledHelpFormatter(width=78) parser = OptionParser(usage=usage, formatter=form, add_help_option=None) _defineCmdLineOptions(parser) # opts - new processed options # args - remainder of the input array opts, args = parser.parse_args(args=args) for mandatory in ("reqMgrUrl", ): if getattr(opts, mandatory, None): break else: errExit(parser) return opts
def _create_parser(): usage = "usage: %prog [options] project" parser = OptionParser(description='Export event logs and anonymised user information of a game.', usage=usage, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-u", "--user", action="store", dest="user", help="Hub login username (will be requested if not provided)") parser.add_option("-p", "--password", action="store", dest="password", help="Hub login password (will be requested if not provided)") parser.add_option("-t", "--type", action="store", dest="datatype", default=DATATYPE_DEFAULT, help="type of data to download, either events or users (defaults to " + DATATYPE_DEFAULT + ")") parser.add_option("-d", "--daterange", action="store", dest="daterange", default=DATERANGE_DEFAULT, help="individual 'yyyy-mm-dd' or range 'yyyy-mm-dd : yyyy-mm-dd' of dates to get the data for " \ "(defaults to today)") parser.add_option("-o", "--outputdir", action="store", dest="outputdir", help="folder to output the downloaded files to (defaults to current directory)") #use json2json for this #parser.add_option("-m", "--merge", action="store", dest="outputfilename", # help="if the data to be downloaded is across multiple files, merge it into one file") parser.add_option("-w", "--overwrite", action="store_true", dest="overwrite", default=False, help="if a file to be downloaded exists in the output directory, " \ "overwrite instead of skipping it") parser.add_option("--indent", action="store_true", dest="indent", default=False, help="apply indentation to the JSON output") parser.add_option("--hub", action="store", dest="hub", default=HUB_URL, help="Hub url (defaults to https://hub.turbulenz.com/)") return parser
def __init__(self): TitledHelpFormatter.__init__(self)
def standard_parser(description, epilog=None, per_file_options=True): """Standard set of parser options.""" parser = OptionParser(description=description, epilog=epilog, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number to output " "file, or stdout if no output file is given") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose outout") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") if per_file_options: parser.add_option("-m", "--metrics", action="store_true", dest="metrics", default=False, help="output asset " "metrics") parser.add_option("--log", action="store", dest="output_log", default=None, help="write log to file") group = OptionGroup(parser, "Asset Generation Options") group.add_option("-j", "--json_indent", action="store", dest="json_indent", type="int", default=0, metavar="SIZE", help="json output pretty printing indent size, defaults " "to 0") # TODO - Asset Generation Options currently disabled # #group.add_option("-6", "--base64-encoding", action="store_true", dest="b64_encoding", default=False, # help=("encode long float and int attributes in base64, defaults to disabled %s" % # "- [ currently unsupported ]")) #group.add_option("-c", "--force-collision", action="store_true", dest="force_collision", default=False, # help="force collision generation - [ currently unsupported ]") #group.add_option("-r", "--force-render", action="store_true", dest="force_render", default=False, # help="force rendering generation - [ currently unsupported ]") group.add_option("--keep-unused-images", action="store_true", dest="keep_unused_images", default=False, help="keep images with no references to them") group.add_option("-I", "--include-type", action="append", dest="include_types", default=None, metavar="TYPE", help="only include objects of class TYPE in export.") group.add_option( "-E", "--exclude-type", action="append", dest="exclude_types", default=None, metavar="TYPE", help="exclude objects of class TYPE from export. " "Classes currently supported for include and exclude: " "geometries, nodes, animations, images, effects, materials, lights, " "physicsmaterials, physicsmodels and physicsnodes. " "CAUTION using these options can create incomplete assets which require fixup at runtime. " ) parser.add_option_group(group) group = OptionGroup(parser, "Asset Location Options") group.add_option("-u", "--url", action="store", dest="asset_url", default="", metavar="URL", help="asset URL to prefix to all asset references") group.add_option("-a", "--assets", action="store", dest="asset_root", default=".", metavar="PATH", help="PATH of the asset root") group.add_option("-d", "--definitions", action="append", dest="definitions", default=None, metavar="JSON_FILE", help="definition JSON_FILE to include in build, " "this option can be used repeatedly for multiple files") parser.add_option_group(group) if per_file_options: group = OptionGroup(parser, "File Options") group.add_option("-i", "--input", action="store", dest="input", default=None, metavar="FILE", help="source FILE to process") group.add_option("-o", "--output", action="store", dest="output", default="default.json", metavar="FILE", help="output FILE to write to") parser.add_option_group(group) # TODO - Database Options are currently disabled # #group = OptionGroup(parser, "Database Options") #group.add_option("-A", "--authority", action="store", dest="authority", default=None, # metavar="HOST:PORT", # help=("Authority of the database in the form HOST:PORT. %s" %s # "If undefined, database export is disabled.")) #group.add_option("-D", "--database", action="store", dest="database", default="default", # metavar="NAME", help="NAME of the document database") #group.add_option("-P", "--put-post", action="store_true", dest="put_post", default=False, # help="put or post the asset to the authority database") #group.add_option("-O", "--document", action="store", dest="document", default="default.asset", # metavar="NAME", help="NAME of the document") #parser.add_option_group(group) return parser
def bmfont2json_parser(description, epilog=None): """Standard set of parser options.""" parser = OptionParser(description=description, epilog=epilog, formatter=TitledHelpFormatter()) parser.add_option("--version", action="store_true", dest="output_version", default=False, help="output version number") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose outout") parser.add_option("-s", "--silent", action="store_true", dest="silent", default=False, help="silent running") parser.add_option("-m", "--metrics", action="store_true", dest="metrics", default=False, help="output asset metrics") parser.add_option("--log", action="store", dest="output_log", default=None, help="write log to file") group = OptionGroup(parser, "Asset Generation Options") group.add_option( "-j", "--json_indent", action="store", dest="json_indent", type="int", default=0, metavar="SIZE", help="json output pretty printing indent size, defaults to 0") parser.add_option_group(group) group = OptionGroup(parser, "Asset Location Options") group.add_option("-p", "--prefix", action="store", dest="texture_prefix", default="textures/", metavar="URL", help="texture URL to prefix to all texture references") group.add_option("-a", "--assets", action="store", dest="asset_root", default=".", metavar="PATH", help="PATH of the asset root") parser.add_option_group(group) group = OptionGroup(parser, "File Options") group.add_option("-i", "--input", action="store", dest="input", default=None, metavar="FILE", help="source FILE to process") group.add_option("-o", "--output", action="store", dest="output", default="default.json", metavar="FILE", help="output FILE to write to") parser.add_option_group(group) return parser
nreport = 1 min_spacer = 0 max_spacer = 13 #cutoffs = [-100,13.7,14.7,15.9,14.8,13.8,15.2,15.6,13.4,14.3,13.0,14.7,13.4,15.5] cutoffs = [ 4.393, 13.7, 14.7, 15.9, 14.8, 13.8, 15.2, 15.6, 13.4, 14.3, 13.0, 14.7, 13.4, 15.5 ] id = "p53bs" SCORE_FRACTION = 0.85 usage = "usage: %prog -i <FILE> [optional arguments]" parser = OptionParser(version=VERSION, usage=usage, formatter=TitledHelpFormatter(max_help_position=40, short_first=1)) parser.add_option("-i", "--input", dest="inputfile", help="FASTA-formatted inputfile", metavar="FILE") parser.add_option("-n", "--nreport", dest="nreport", help="report the N best matches", metavar="N") parser.add_option("-p", "--pwm", dest="pwmfile", help="specify your own PWM file", metavar="FILE")
def main(): """ReportBuilder main.""" parser = OptionParser(USAGE, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("-H", "--html", action="store_true", default=False, dest="html", help="Produce an html report.") parser.add_option("--org", action="store_true", default=False, dest="org", help="Org-mode report.") parser.add_option("-P", "--with-percentiles", action="store_true", default=True, dest="with_percentiles", help=("Include percentiles in tables, use 10%, 50% and" " 90% for charts, default option.")) parser.add_option("--no-percentiles", action="store_false", dest="with_percentiles", help=("No percentiles in tables display min, " "avg and max in charts.")) cur_path = os.path.abspath(os.path.curdir) parser.add_option("-d", "--diff", action="store_true", default=False, dest="diffreport", help=("Create differential report.")) parser.add_option("-t", "--trend", action="store_true", default=False, dest="trendreport", help=("Build a trend reprot.")) parser.add_option("-o", "--output-directory", type="string", dest="output_dir", help="Parent directory to store reports, the directory" "name of the report will be generated automatically.", default=cur_path) parser.add_option("-r", "--report-directory", type="string", dest="report_dir", help="Directory name to store the report.", default=None) parser.add_option( "-T", "--apdex-T", type="float", dest="apdex_t", help="Apdex T constant in second, default is set to 1.5s. " "Visit http://www.apdex.org/ for more information.", default=Apdex.T) parser.add_option("-x", "--css", type="string", dest="css_file", help="Custom CSS file to use for the HTML reports", default=None) parser.add_option("", "--skip-definitions", action="store_true", default=False, dest="skip_definitions", help="If True, will skip the definitions") parser.add_option("-q", "--quiet", action="store_true", default=False, dest="quiet", help=("Report no system messages when generating" " html from rst.")) options, args = parser.parse_args() if options.diffreport: if len(args) != 2: parser.error("incorrect number of arguments") trace("Creating diff report ... ") output_dir = options.output_dir html_path = RenderDiff(args[0], args[1], options, css_file=options.css_file) trace("done: \n") trace("%s\n" % html_path) elif options.trendreport: if len(args) < 2: parser.error("incorrect number of arguments") trace("Creating trend report ... ") output_dir = options.output_dir html_path = RenderTrend(args, options, css_file=options.css_file) trace("done: \n") trace("%s\n" % html_path) else: if len(args) < 1: parser.error("incorrect number of arguments") if len(args) > 1: trace("Merging results files: ") f = NamedTemporaryFile(prefix='fl-mrg-', suffix='.xml') tmp_file = f.name f.close() MergeResultFiles(args, tmp_file) trace("Results merged in tmp file: %s\n" % os.path.abspath(tmp_file)) args = [tmp_file] options.xml_file = args[0] Apdex.T = options.apdex_t xml_parser = FunkLoadXmlParser() xml_parser.parse(options.xml_file) if options.html: trace("Creating html report: ...") html_path = RenderHtml(xml_parser.config, xml_parser.stats, xml_parser.error, xml_parser.monitor, xml_parser.monitorconfig, options, css_file=options.css_file)() trace("done: \n") trace(html_path + "\n") elif options.org: from ReportRenderOrg import RenderOrg print unicode( RenderOrg(xml_parser.config, xml_parser.stats, xml_parser.error, xml_parser.monitor, xml_parser.monitorconfig, options)).encode("utf-8") else: print unicode( RenderRst(xml_parser.config, xml_parser.stats, xml_parser.error, xml_parser.monitor, xml_parser.monitorconfig, options)).encode("utf-8")
def format_description(self, description): if description: return "".join( [TitledHelpFormatter.format_description(self,d) for d in description.split("\n\n")]) else: return ""
def format_epilog(self,epilog): if epilog: return "\n"+("-"*int(self.width/2))+"\n"+"".join( [TitledHelpFormatter.format_epilog(self,d) for d in epilog.split("\n\n")]) else: return ""