Python argparse.RawDescriptionHelpFormatter() Examples
The following are 30
code examples of argparse.RawDescriptionHelpFormatter().
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
argparse
, or try the search function
.
Example #1
Source File: apply_bpe.py From crosentgec with GNU General Public License v3.0 | 8 votes |
def create_parser(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="learn BPE-based word segmentation") parser.add_argument( '--input', '-i', type=argparse.FileType('r'), default=sys.stdin, metavar='PATH', help="Input file (default: standard input).") parser.add_argument( '--codes', '-c', type=argparse.FileType('r'), metavar='PATH', required=True, help="File with BPE codes (created by learn_bpe.py).") parser.add_argument( '--output', '-o', type=argparse.FileType('w'), default=sys.stdout, metavar='PATH', help="Output file (default: standard output)") parser.add_argument( '--separator', '-s', type=str, default='@@', metavar='STR', help="Separator between non-final subword units (default: '%(default)s'))") return parser
Example #2
Source File: provider_base.py From dsub with Apache License 2.0 | 6 votes |
def create_parser(prog): """Create an argument parser, adding in the list of providers.""" parser = argparse.ArgumentParser( prog=prog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--provider', default='google-v2', choices=['local', 'google-v2', 'google-cls-v2', 'test-fails'], help="""Job service provider. Valid values are "google-v2" (Google's Pipeline API v2alpha1), "google-cls-v2" (Google's Pipelines API v2beta) and "local" (local Docker execution). "test-*" providers are for testing purposes only. (default: google-v2)""", metavar='PROVIDER') return parser
Example #3
Source File: pycozmo_anim.py From pycozmo with MIT License | 6 votes |
def parse_arguments(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) subparsers = parser.add_subparsers(dest="cmd", required=True) subparser = subparsers.add_parser("info", help="view clips and keyframes in an animation file") subparser.add_argument("input", help="input file specification") subparser = subparsers.add_parser( "json", help="convert an animation in FlatBuffers format to JSON format") subparser.add_argument("input", help="input file specification") subparser.add_argument("-o", "--output", help="output file specification") subparser = subparsers.add_parser( "bin", help="convert an animation in JSON format to FlatBuffers format.") subparser.add_argument("input", help="input file specification") subparser.add_argument("-o", "--output", help="output file specification") subparser = subparsers.add_parser("images", help="export procedural face images from an animation file") subparser.add_argument("input", help="input file specification") subparser.add_argument("-p", "--prefix", help="output file specification prefix") args = parser.parse_args() return args
Example #4
Source File: scp_to_infercnv.py From single_cell_portal with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create_parser(): """Set up parsing for command-line arguments """ parser = argparse.ArgumentParser(description=__doc__, # Use text from file summary up top formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--reference-cluster-path', dest='ref_cluster_path', help='Path to SCP cluster file to use as reference ' + '(i.e. normal, control) cells') parser.add_argument('--reference-group-name', dest='ref_group_name', help='Name of cell group in SCP cluster file to use as ' + 'label for inferCNV references') parser.add_argument('--metadata-path', help='Path to SCP metadata file that contains all cells') parser.add_argument('--observation-group-name', dest='obs_group_name', help='Name of the cell group in SCP metadata file to ' + 'use as label for observations') parser.add_argument('--delimiter', help='Delimiter in SCP cluster file', default="\t") parser.add_argument('--output-dir', help='Path to write output') return parser
Example #5
Source File: run.py From monasca-analytics with Apache License 2.0 | 6 votes |
def setup_parser(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=textwrap.dedent(__doc__.strip()), add_help=False) parser.add_argument('-c', '--config', help='Config file.', required=True) # "-d" currently unused parser.add_argument('-d', '--debug', help='Show debug messages.', action='store_true') parser.add_argument('-h', '--help', help='Show this screen.', action='help') parser.add_argument('-l', '--log_config', help='Log config file\'s path.', required=True) parser.add_argument('-p', '--spark_path', help='Spark\'s path.', required=True) parser.add_argument('-s', '--sources', help='A list of data sources.', nargs='*') parser.add_argument('-v', '--version', help='Show version.', action='version', version=setup_property.VERSION) return parser
Example #6
Source File: cmd_utils.py From godot-mono-builds with MIT License | 6 votes |
def build_arg_parser(description, env_vars={}): from argparse import ArgumentParser, RawDescriptionHelpFormatter from textwrap import dedent base_env_vars = { 'MONO_SOURCE_ROOT': 'Overrides default value for --mono-sources', } env_vars_text = '\n'.join([' %s: %s' % (var, desc) for var, desc in env_vars.items()]) base_env_vars_text = '\n'.join([' %s: %s' % (var, desc) for var, desc in base_env_vars.items()]) epilog=dedent('''\ environment variables: %s %s ''' % (env_vars_text, base_env_vars_text)) return ArgumentParser( description=description, formatter_class=RawDescriptionHelpFormatter, epilog=epilog )
Example #7
Source File: tempest_results_processor.py From JetPack with Apache License 2.0 | 6 votes |
def _create_parser(): parser = ArgumentParser(description="Compare two tempest xml results", formatter_class=RawDescriptionHelpFormatter) parser.add_argument("result_1", help="path to xml result 1") parser.add_argument("result_2", help="path to xml result 2") '''TODO future functionality parser.add_argument("-c", "--csv", dest="output_csv", action="store_true", help="output csv") parser.add_argument("-m", "--html", dest="output_html", action="store_true", help="output html") parser.add_argument("-n", "--json", dest="output_json", action="store_true", help="output json") parser.add_argument("-o", "--output-file", dest="output_file", type=str, required=False, help="If specified, output will be saved to given " "file") ''' return parser
Example #8
Source File: extractPage.py From SOQAL with MIT License | 6 votes |
def main(): parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]), formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__) parser.add_argument("input", help="XML wiki dump file") parser.add_argument("--id", default="", help="article number, or range first-last") parser.add_argument("--template", action="store_true", help="extract also all templates") parser.add_argument("-v", "--version", action="version", version='%(prog)s ' + version, help="print program version") args = parser.parse_args() process_data(args.input, args.id, args.template)
Example #9
Source File: __main__.py From jwalk with Apache License 2.0 | 6 votes |
def create_parser(): parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter) parser.add_argument('--debug', action='store_true') parser.add_argument('--delimiter') parser.add_argument('--embedding-size', default=200, type=int) parser.add_argument('--graph-path') parser.add_argument('--has-header', action='store_true') parser.add_argument('--input', '-i', dest='infile', required=True) parser.add_argument('--log-level', '-l', type=str.upper, default='INFO') parser.add_argument('--num-walks', default=1, type=int) parser.add_argument('--model', '-m', dest='model_path') parser.add_argument('--output', '-o', dest='outfile', required=True) parser.add_argument('--stats', action='store_true') parser.add_argument('--undirected', action='store_true') parser.add_argument('--walk-length', default=10, type=int) parser.add_argument('--window-size', default=5, type=int) parser.add_argument('--workers', default=multiprocessing.cpu_count(), type=int) return parser
Example #10
Source File: Cli.py From URS with MIT License | 6 votes |
def parse_args(self): parser = argparse.ArgumentParser( description = self._description, epilog = self._epilog, formatter_class = argparse.RawDescriptionHelpFormatter, usage = self._usage) self._add_flags(parser) self._add_export(parser) ### Print help message if no arguments are present. if len(sys.argv[1:]) == 0: parser.print_help() raise SystemExit args = parser.parse_args() return args, parser
Example #11
Source File: base.py From pydarkstar with MIT License | 6 votes |
def __init__(self, config='config.yaml', description=None): super(BaseOptions, self).__init__() logging.debug('BaseOptions.__init__') self._ordered_keys = [] self._exclude_keys = set() self._parent = argparse.ArgumentParser(add_help=False) self._parser = argparse.ArgumentParser(parents=[self._parent], description=description, formatter_class=argparse.RawDescriptionHelpFormatter) # config file option self.config = config # config file self._parent.add_argument('--config', type=str, default=self.config, metavar=self.config, help='configuration file name')
Example #12
Source File: galaxykickstart_from_workflow.py From GalaxyKickStart with GNU General Public License v3.0 | 6 votes |
def _parse_cli_options(): """ Parse command line options, returning `parse_args` from `ArgumentParser`. """ parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, usage="python %(prog)s <options>", epilog="example:\n" "python %(prog)s -w workflow1 workflow2 -l my_panel_label\n" "Christophe Antoniewski <drosofff@gmail.com>\n" "https://github.com/ARTbio/ansible-artimed/tree/master/scritps/galaxykickstart_from_workflow.py") parser.add_argument('-w', '--workflow', dest="workflow_files", required=True, nargs='+', help='A space-separated list of galaxy workflow description files in json format', ) parser.add_argument('-l', '--panel_label', dest='panel_label', default='Tools from workflows', help='The name of the panel where the tools will show up in Galaxy.' 'If not specified: "Tools from workflows"') return parser.parse_args()
Example #13
Source File: args.py From ccat with GNU General Public License v3.0 | 6 votes |
def getfilenames(): global args parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description="Cisco Configuration Analysis Tool", epilog='Usage example:\n ccat smth/config_folder -vlanmap smth/vlanmap_file') parser.add_argument("configs", type=str, nargs='?', default=0, help="full path to the configuration file or folder with config(s)") parser.add_argument("-vlanmap", type=str, help="path to vlanmap (file that determine how critical is certain vlan, you can find example in 'example' folder)") parser.add_argument("-output", type=str, help="path to output html files directory") parser.add_argument("--no-console-display", action='store_true', help="to output analysis results in html files directory or into network graph") parser.add_argument("--no-ipv6", action='store_true', help="if you're not using IPv6") parser.add_argument("--disabled-interfaces", action='store_true', help="check interfaces even if they are turned off") parser.add_argument("--storm_level", type=float, help="to set up appropriate level for storm-control (by default value=80)") parser.add_argument("--max_number_mac", type=int, help="to set up maximum number of mac-addresses for port-security (by default value=10)") parser.add_argument("--dump-creds", action='store_true', help="enable credentials harvesting") parser.add_argument("--debug", action='store_true', help="enable debug output") graph_group = parser.add_argument_group('Network graph') graph_group.add_argument("--graph", type=str, nargs='?', default=0, help="left the argument empty to get into interactive mode or define a file name for graph output in png extension") args = parser.parse_args() if not(args.configs): print ('Usage example:\n ccat smth/config_folder -vlanmap smth/vlanmap_file\n\nFor more details try --help') exit() if args.no_console_display and not args.output and args.graph == 0: print('\nYou should define html files directory with -output key OR use --graph key to use this options\n\nFor more details try --help') exit() return _getargs___arg_parser(args.configs, args.vlanmap)
Example #14
Source File: getTGS.py From minikerberos with MIT License | 6 votes |
def main(): import argparse parser = argparse.ArgumentParser(description='Polls the kerberos service for a TGS for the sepcified user and specified service', formatter_class=argparse.RawDescriptionHelpFormatter, epilog = kerberos_url_help_epilog) parser.add_argument('kerberos_connection_string', help='the kerberos target string in the following format <domain>/<username>/<secret_type>:<secret>@<domaincontroller-ip>') parser.add_argument('spn', help='the service principal in format <service>/<server-hostname>@<domain> Example: cifs/fileserver.test.corp@TEST.corp for a TGS ticket to be used for file access on server "fileserver". IMPORTANT: SERVER\'S HOSTNAME MUST BE USED, NOT IP!!!') parser.add_argument('ccache', help='ccache file to store the TGT ticket in') parser.add_argument('-u', action='store_true', help='Use UDP instead of TCP (not tested)') parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() if args.verbose == 0: logging.basicConfig(level=logging.INFO) elif args.verbose == 1: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=1) asyncio.run(amain(args))
Example #15
Source File: getS4U2proxy.py From minikerberos with MIT License | 6 votes |
def main(): import argparse parser = argparse.ArgumentParser(description='Gets an S4U2proxy ticket impersonating given user', formatter_class=argparse.RawDescriptionHelpFormatter, epilog = kerberos_url_help_epilog) parser.add_argument('kerberos_connection_url', help='the kerberos target string in the following format <domain>/<username>/<secret_type>:<secret>@<domaincontroller-ip>') parser.add_argument('spn', help='the service principal in format <service>/<server-hostname>@<domain> Example: cifs/fileserver.test.corp@TEST.corp for a TGS ticket to be used for file access on server "fileserver". IMPORTANT: SERVER\'S HOSTNAME MUST BE USED, NOT IP!!!') parser.add_argument('targetuser', help='') parser.add_argument('ccache', help='ccache file to store the TGT ticket in') parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() if args.verbose == 0: logger.setLevel(logging.WARNING) elif args.verbose == 1: logger.setLevel(logging.INFO) else: logger.setLevel(1) asyncio.run(amain(args))
Example #16
Source File: learn_bpe.py From knmt with GNU General Public License v3.0 | 6 votes |
def create_parser(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="learn BPE-based word segmentation") parser.add_argument( '--input', '-i', type=argparse.FileType('r'), default=sys.stdin, metavar='PATH', help="Input text (default: standard input).") parser.add_argument( '--output', '-o', type=argparse.FileType('w'), default=sys.stdout, metavar='PATH', help="Output file for BPE codes (default: standard output)") parser.add_argument( '--symbols', '-s', type=int, default=10000, help="Create this many new symbols (each representing a character n-gram) (default: %(default)s))") parser.add_argument( '--min-frequency', type=int, default=2, metavar='FREQ', help='Stop if no symbol pair has frequency >= FREQ (default: %(default)s))') parser.add_argument( '--verbose', '-v', action="store_true", help="verbose mode.") return parser
Example #17
Source File: getTGT.py From minikerberos with MIT License | 6 votes |
def main(): import argparse parser = argparse.ArgumentParser(description='Polls the kerberos service for a TGT for the sepcified user', formatter_class=argparse.RawDescriptionHelpFormatter, epilog = kerberos_url_help_epilog) parser.add_argument('kerberos_connection_url', help='the kerberos target string. ') parser.add_argument('ccache', help='ccache file to store the TGT ticket in') parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() if args.verbose == 0: logging.basicConfig(level=logging.INFO) elif args.verbose == 1: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=1) asyncio.run(amain(args))
Example #18
Source File: poc_nuuo_upgrade_handle.py From poc with BSD 3-Clause "New" or "Revised" License | 6 votes |
def main(): """ Parse command line arguments and start exploit """ parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.RawDescriptionHelpFormatter, epilog="Examples: %(prog)s -t http://192.168.0.1/ -u username -p password -c whoami") # Adds arguments to help menu parser.add_argument("-h", action="help", help="Print this help message then exit") parser.add_argument("-t", dest="target", required="yes", help="Target URL address like: https://localhost:443/") parser.add_argument("-u", dest="username", required="yes", help="Username to authenticate") parser.add_argument("-p", dest="password", required="yes", help="Password to authenticate") parser.add_argument("-c", dest="command", required="yes", help="Shell command to execute") # Assigns the arguments to various variables args = parser.parse_args() run(args.target, args.username, args.password, args.command) # # Main #
Example #19
Source File: list_blocks.py From sawtooth-core with Apache License 2.0 | 6 votes |
def add_list_blocks_parser(subparsers, parent_parser): """Creates the arg parsers needed for the compare command. """ parser = subparsers.add_parser( 'list-blocks', help='List blocks from different nodes.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog='', parents=[parent_parser, base_multinode_parser()]) parser.add_argument( '-n', '--count', default=10, type=int, help='the number of blocks to list')
Example #20
Source File: __main__.py From safelife with Apache License 2.0 | 6 votes |
def run(): parser = argparse.ArgumentParser(description=""" The SafeLife command-line tool can be used to interactively play a game of SafeLife, print procedurally generated SafeLife boards, or convert saved boards to images for easy viewing. Please select one of the available commands to run the program. You can run `safelife <command> --help` to get more help on a particular command. """, formatter_class=argparse.RawDescriptionHelpFormatter) subparsers = parser.add_subparsers(dest="cmd", help="Top-level command.") interactive_game._make_cmd_args(subparsers) render_graphics._make_cmd_args(subparsers) args = parser.parse_args() if args.cmd is None: parser.print_help() else: args.run_cmd(args)
Example #21
Source File: archive.py From bob with GNU General Public License v3.0 | 6 votes |
def doArchive(argv, bobRoot): subHelp = "\n ... ".join(sorted( [ "{:8} {}".format(c, d[1]) for (c, d) in availableArchiveCmds.items() ])) parser = argparse.ArgumentParser(prog="bob archive", formatter_class=argparse.RawDescriptionHelpFormatter, description="""Manage binary artifacts archive. The following subcommands are available: bob archive {} """.format(subHelp)) parser.add_argument('subcommand', help="Subcommand") parser.add_argument('args', nargs=argparse.REMAINDER, help="Arguments for subcommand") args = parser.parse_args(argv) if args.subcommand in availableArchiveCmds: availableArchiveCmds[args.subcommand][0](args.args) else: parser.error("Unknown subcommand '{}'".format(args.subcommand))
Example #22
Source File: unband.py From kevlar with MIT License | 5 votes |
def subparser(subparsers): """Define the `kevlar unband` command-line interface.""" desc = """\ When kevlar is run in k-mer banding mode, the same read will typically appear in multiple output files, annotated with a different set of potentially novel k-mers in each case. This command will consolidate these duplicated records across files into a single non-redundant set of reads with the complete set of novel k-mer annotations. """ desc = textwrap.dedent(desc) subparser = subparsers.add_parser( 'unband', description=desc, formatter_class=argparse.RawDescriptionHelpFormatter, ) subparser.add_argument( '-n', '--n-batches', metavar='N', type=int, default=16, help='number of batches into which records will be split; default is ' '16; N temporary files are created and each record from the input is ' 'written to a temporary file based on its read name; then each batch ' 'is loaded into memory and duplicate records are resolved' ) subparser.add_argument( '-o', '--out', metavar='FILE', help='output file; default is terminal (stdout)' ) subparser.add_argument( 'infile', nargs='+', help='input files in augmented Fasta/Fastq format' )
Example #23
Source File: register_wsg.py From visual_foresight with MIT License | 5 votes |
def main(): """RSDK URDF Fragment Example: This example shows a proof of concept for adding your URDF fragment to the robot's onboard URDF (which is currently in use). """ arg_fmt = argparse.RawDescriptionHelpFormatter parser = argparse.ArgumentParser(formatter_class=arg_fmt, description=main.__doc__) required = parser.add_argument_group('required arguments') required.add_argument( '-f', '--file', metavar='PATH', required=True, help='Path to URDF file to send' ) required.add_argument( '-l', '--link', required=False, default="right_hand", #parent help='URDF Link already to attach fragment to (usually <left/right>_hand)' ) required.add_argument( '-j', '--joint', required=False, default="right_gripper_base", help='Root joint for fragment (usually <left/right>_gripper_base)' ) parser.add_argument("-d", "--duration", type=lambda t:abs(float(t)), default=5.0, help="[in seconds] Duration to publish fragment") args = parser.parse_args(rospy.myargv()[1:]) rospy.init_node('rsdk_configure_urdf', anonymous=True) if not os.access(args.file, os.R_OK): rospy.logerr("Cannot read file at '%s'" % (args.file,)) return 1 send_urdf(args.link, args.joint, args.file, args.duration) return 0
Example #24
Source File: __init__.py From kevlar with MIT License | 5 votes |
def parser(): bubbletext = r''' ≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠ ┌ ┐ ┌ ┐ | | | | | | _______ _| | __ _ _ __ | |/ / _ \ \ / / |/ _` | '__| | < __/\ V /| | (_| | | reference-free variant discovery in |_|\_\___| \_/ |_|\__,_|_| large eukaryotic genomes ≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠ ''' subcommandstr = '", "'.join(sorted(list(mains.keys()))) parser = argparse.ArgumentParser( description=bubbletext, formatter_class=argparse.RawDescriptionHelpFormatter, ) parser._positionals.title = 'Subcommands' parser._optionals.title = 'Global arguments' parser.add_argument('-v', '--version', action='version', version='kevlar v{}'.format(kevlar.__version__)) parser.add_argument('-l', '--logfile', metavar='F', help='log file for ' 'diagnostic messages, warnings, and errors') parser.add_argument('--tee', action='store_true', help='write diagnostic ' 'output to logfile AND terminal (stderr)') subparsers = parser.add_subparsers(dest='cmd', metavar='cmd', help='"' + subcommandstr + '"') for func in subparser_funcs.values(): func(subparsers) return parser
Example #25
Source File: helm.py From appr with Apache License 2.0 | 5 votes |
def _add_arguments(cls, parser): from appr.commands.cli import get_parser, all_commands sub = parser.add_subparsers() install_cmd = sub.add_parser( 'install', help="Fetch the Chart and execute `helm install`", formatter_class=argparse.RawDescriptionHelpFormatter, description=helm_description( "install", "$ appr helm install quay.io/ant31/cookieapp -- --set imageTag=v0.4.5 --namespace demo" ), epilog="\nhelm options:\n See 'helm install --help'") upgrade_cmd = sub.add_parser( 'upgrade', help="Fetch the Chart and execute `helm upgrade`", formatter_class=argparse.RawDescriptionHelpFormatter, description=helm_description( "upgrade", "$ appr helm upgrade quay.io/ant31/cookieapp -- release-name --set foo=bar --set foo=newbar" ), epilog="\nhelm options:\n See 'helm upgrade --help'") dep_pull_cmd = sub.add_parser( 'dep', help="Download Charts from the requirements.yaml using app-registry") cls._init_dep_args(dep_pull_cmd) cls._init_args(install_cmd) cls._init_args(upgrade_cmd) install_cmd.set_defaults(func=cls._install) upgrade_cmd.set_defaults(func=cls._upgrade) dep_pull_cmd.set_defaults(func=cls._dep_pull) other_cmds = copy(all_commands()) other_cmds.pop("helm") get_parser(other_cmds, parser, sub, {'APPR_DEFAULT_MEDIA_TYPE': 'helm'})
Example #26
Source File: cmdLineUtils.py From parliament2 with Apache License 2.0 | 5 votes |
def _getParser(theHelp, theEpilog): """ Get a commandline parser with the defaults of the commandline utils. """ return argparse.ArgumentParser(description=theHelp, formatter_class=argparse.RawDescriptionHelpFormatter, epilog = theEpilog)
Example #27
Source File: apply_bpe.py From ITDD with MIT License | 5 votes |
def create_parser(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="learn BPE-based word segmentation") parser.add_argument( '--input', '-i', type=argparse.FileType('r'), default=sys.stdin, metavar='PATH', help="Input file (default: standard input).") parser.add_argument( '--codes', '-c', type=argparse.FileType('r'), metavar='PATH', required=True, help="File with BPE codes (created by learn_bpe.py).") parser.add_argument( '--output', '-o', type=argparse.FileType('w'), default=sys.stdout, metavar='PATH', help="Output file (default: standard output)") parser.add_argument( '--separator', '-s', type=str, default='@@', metavar='STR', help="Separator between non-final subword units (default: '%(default)s'))") parser.add_argument( '--vocabulary', type=argparse.FileType('r'), default=None, metavar="PATH", help="Vocabulary file (built with get_vocab.py). If provided, this script reverts any merge operations that produce an OOV.") parser.add_argument( '--vocabulary-threshold', type=int, default=None, metavar="INT", help="Vocabulary threshold. If vocabulary is provided, any word with frequency < threshold will be treated as OOV") parser.add_argument( '--glossaries', type=str, nargs='+', default=None, metavar="STR", help="Glossaries. The strings provided in glossaries will not be affected" + "by the BPE (i.e. they will neither be broken into subwords, nor concatenated with other subwords") return parser
Example #28
Source File: learn_bpe.py From ITDD with MIT License | 5 votes |
def create_parser(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="learn BPE-based word segmentation") parser.add_argument( '--input', '-i', type=argparse.FileType('r'), default=sys.stdin, metavar='PATH', help="Input text (default: standard input).") parser.add_argument( '--output', '-o', type=argparse.FileType('w'), default=sys.stdout, metavar='PATH', help="Output file for BPE codes (default: standard output)") parser.add_argument( '--symbols', '-s', type=int, default=10000, help="Create this many new symbols (each representing a character n-gram) (default: %(default)s))") parser.add_argument( '--min-frequency', type=int, default=2, metavar='FREQ', help='Stop if no symbol pair has frequency >= FREQ (default: %(default)s))') parser.add_argument('--dict-input', action="store_true", help="If set, input file is interpreted as a dictionary where each line contains a word-count pair") parser.add_argument( '--verbose', '-v', action="store_true", help="verbose mode.") return parser
Example #29
Source File: projects_json2yml.py From grimoirelab-sirmordred with GNU General Public License v3.0 | 5 votes |
def read_arguments(): desc = "Convert JSON to YML: return hierarchy.yml and projects_repo.yml" parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=desc) parser.add_argument("json_file", action="store", help="JSON file: input") args = parser.parse_args() return args
Example #30
Source File: render_graphics.py From safelife with Apache License 2.0 | 5 votes |
def _make_cmd_args(subparsers): # used by __main__.py to define command line tools from argparse import RawDescriptionHelpFormatter import textwrap parser = subparsers.add_parser( "render", help="Convert a SafeLife level to either a png or a gif.", description=textwrap.dedent(""" Convert a SafeLife level to either a png or a gif. Static SafeLife levels can be saved while editing them during interactive play, and an agent's actions can be saved either during training or while recording interactive play. Either way, the data will be saved in .npz files. Static files will get rendered to png, while recorded actions will be compiled into an animated gif. """), formatter_class=RawDescriptionHelpFormatter) parser.add_argument('fnames', help="File(s) to render.", nargs='+') parser.add_argument('--steps', default=0, type=int, help="Static output can be turned into animated output by setting" " this to be non-zero. If non-zero, it determines the number of" " steps that the board animation runs during animation, with one" " step for each frame.") parser.add_argument('--fps', default=30, type=float, help="Frames per second for animated outputs.") parser.add_argument('--fmt', default='gif', help="Format for video rendering. " "Can either be 'gif' or one of the formats supported by ffmpeg " "(e.g., mp4, avi, etc.).") parser.set_defaults(run_cmd=_run_cmd_args)