Python argparse.RawTextHelpFormatter() Examples
The following are 30 code examples for showing how to use argparse.RawTextHelpFormatter(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
argparse
, or try the search function
.
Example 1
Project: DNA-GAN Author: Prinsphield File: train.py License: MIT License | 6 votes |
def main(): parser = argparse.ArgumentParser(description='test', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument( '-a', '--attributes', nargs='+', type=str, help='Specify attribute name for training. \nAll attributes can be found in list_attr_celeba.txt' ) parser.add_argument( '-g', '--gpu', default='0', type=str, help='Specify GPU id. \ndefault: %(default)s. \nUse comma to seperate several ids, for example: 0,1' ) args = parser.parse_args() celebA = Dataset(args.attributes) DNA_GAN = Model(args.attributes, is_train=True) run(config, celebA, DNA_GAN, gpu=args.gpu)
Example 2
Project: toil-scripts Author: BD2KGenomics File: transfer_gtex_to_s3.py License: Apache License 2.0 | 6 votes |
def build_parser(): parser = argparse.ArgumentParser(description=main.__doc__, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-s', '--sra', default=None, required=True, help='Path to a file with one analysis ID per line for data hosted on CGHub.') parser.add_argument('-k', '--dbgap_key', default=None, required=True, help='Path to a CGHub key that has access to the TCGA data being requested. An exception will' 'be thrown if "-g" is set but not this argument.') parser.add_argument('--s3_dir', default=None, required=True, help='S3 Bucket. e.g. tcga-data') parser.add_argument('--ssec', default=None, required=True, help='Path to Key File for SSE-C Encryption') parser.add_argument('--single_end', default=None, action='store_true', help='Set this flag if data is single-end') parser.add_argument('--sudo', dest='sudo', default=None, action='store_true', help='Docker usually needs sudo to execute locally, but not when running Mesos or when ' 'the user is a member of a Docker group.') return parser # Convenience Functions
Example 3
Project: aetros-cli Author: aetros File: PredictCommand.py License: MIT License | 6 votes |
def main(self, args): from aetros.predict import predict parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, prog=aetros.const.__prog__ + ' predict') parser.add_argument('id', nargs='?', help='the job id, e.g. peter/mnist/5d0f81d3ea73e8b2da3236c93f502339190c7037') parser.add_argument('--weights', help="Weights path. Per default we try to find it in the ./weights/ folder.") parser.add_argument('-i', nargs='+', help="Input (path or url). Multiple allowed") parsed_args = parser.parse_args(args) if not parsed_args.id: parser.print_help() sys.exit() if not parsed_args.i: parser.print_help() sys.exit() os.environ['KERAS_BACKEND'] = 'tensorflow' predict(self.logger, parsed_args.id, parsed_args.i, parsed_args.weights)
Example 4
Project: aetros-cli Author: aetros File: IdCommand.py License: MIT License | 6 votes |
def main(self, args): import aetros.const parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, prog=aetros.const.__prog__ + ' id') parsed_args = parser.parse_args(args) config = read_home_config() try: user = api.user() except KeyNotConfiguredException as e: self.logger.error(str(e)) sys.exit(1) print("Logged in as %s (%s) on %s" % (user['username'], user['name'], config['host'])) if len(user['accounts']) > 0: for orga in six.itervalues(user['accounts']): print(" %s of organisation %s (%s)." % ("Owner" if orga['memberType'] == 1 else "Member", orga['username'], orga['name'])) else: print(" Without membership to an organisation.")
Example 5
Project: aetros-cli Author: aetros File: ModelCommand.py License: MIT License | 6 votes |
def main(self, args): import aetros.const parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, prog=aetros.const.__prog__ + ' model') parsed_args = parser.parse_args(args) home_config = read_home_config() config_path = find_config_path() if not config_path: print("No model configuration file (aetros.yml). Switch to a directory first..") sys.exit(1) config = find_config(error_on_missing=True) print("Model %s in %s used in all aetros commands." % (config['model'], os.path.dirname(config_path))) git_remote_url = 'git@%s:%s.git' % (home_config['host'], config['model']) print("Git url: %s" % (git_remote_url,))
Example 6
Project: aetros-cli Author: aetros File: GPUCommand.py License: MIT License | 6 votes |
def main(self, args): import aetros.cuda_gpu parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, prog=aetros.const.__prog__ + ' gpu') try: print("CUDA version: " +str(aetros.cuda_gpu.get_version())) except aetros.cuda_gpu.CudaNotImplementedException: sys.stderr.write('It seems you dont have NVIDIA CUDA not installed properly.') sys.exit(2) for gpu in aetros.cuda_gpu.get_ordered_devices(): properties = aetros.cuda_gpu.get_device_properties(gpu['device'], all=True) free, total = aetros.cuda_gpu.get_memory(gpu['device']) print("%s GPU id=%s %s (memory %.2fGB, free %.2fGB)" %(gpu['fullId'], str(gpu['id']), properties['name'], total/1024/1024/1024, free/1024/1024/1024))
Example 7
Project: BerePi Author: jeonghoonkang File: save_list_2_excel.py License: BSD 2-Clause "Simplified" License | 6 votes |
def parse_args(): story = u"파일명, 데이터 시작셀과 마지막셀 입력" usg = u'\n python save_list.py -fname "sample" -s T4 -e T38' parser = argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("-f", default="sample", help=u"파일명, e.g.) sample") parser.add_argument("-s", default='T4', help=u"데이터 시작 셀, e.g.) T4") parser.add_argument("-e", default='T38', help=u"데이터 마지막 셀, e.g.) T38") parser.add_argument("-n", default='test.py', help=u"생성할 파일명, e.g) test.py") args = parser.parse_args() # check f = args.f s = args.s e = args.e n = args.n return f, s, e, n
Example 8
Project: BerePi Author: jeonghoonkang File: save_excel_2_list.py License: BSD 2-Clause "Simplified" License | 6 votes |
def parse_args(): story = u"파일명, 데이터 시작셀과 마지막셀 입력" usg = u'\n python save_list.py -f "sample" -t 0 -s T4 -e T38' parser = argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("-f", default="2017-07-24 17.12.00_new_ee_with_DB", help=u"파일명") parser.add_argument("-t", default="0", help=u"Sheet Tab: 0, 1, 2 ...") parser.add_argument("-s", default='G2', help=u"데이터 시작 셀") parser.add_argument("-e", default='G746', help=u"데이터 마지막 셀") args = parser.parse_args() # check f = args.f t = args.t s = args.s e = args.e return f, t, s, e
Example 9
Project: MMM-GoogleAssistant Author: gauravsacc File: assistant.py License: MIT License | 6 votes |
def init_googleAssistant(): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--credentials', type=existing_file, metavar='OAUTH2_CREDENTIALS_FILE', default=os.path.join( os.path.expanduser('/home/pi/.config'), 'google-oauthlib-tool', 'credentials.json' ), help='Path to store and read OAuth2 credentials') args = parser.parse_args() with open(args.credentials, 'r') as f: credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f)) with Assistant(credentials,"magic-mirror-device-id") as assistant: for event in assistant.start(): process_event(event)
Example 10
Project: 3gpp-citations Author: martisak File: standardcitations.py License: MIT License | 6 votes |
def parse_args(args): """ Parse arguments """ parser = argparse.ArgumentParser( description=DESCRIPTION, epilog=EPILOG, formatter_class=RawTextHelpFormatter) parser.add_argument('--input', '-i', metavar='INPUT', required=True, help=('The Excel file generated by and ' 'exported from the 3GPP Portal ' '(https://portal.3gpp.org)')) parser.add_argument('--output', '-o', metavar='OUTPUT', help=('The bib file to write to. ' 'STDOUT is used if omitted.')) parser.add_argument('--xelatex', action='store_true', help='Use line breaks') args = parser.parse_args(args) return args
Example 11
Project: grimoire Author: RUB-SysSec File: config.py License: GNU Affero General Public License v3.0 | 6 votes |
def __load_arguments(self): modes = ["m32", "m64"] modes_help = 'm32\tpack and compile as an i386 executable.\n' \ 'm64\tpack and compile as an x86-64 executable.\n' parser = ArgsParser(formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('binary_file', metavar='<Executable>', action=FullPath, type=parse_is_file, help='path to the user space executable file.') parser.add_argument('output_dir', metavar='<Output Directory>', action=FullPath, type=parse_is_dir, help='path to the output directory.') parser.add_argument('mode', metavar='<Mode>', choices=modes, help=modes_help) parser.add_argument('-args', metavar='<args>', help='define target arguments.', default="", type=str) parser.add_argument('-file', metavar='<file>', help='write payload to file instead of stdin.', default="", type=str) parser.add_argument('--recompile', help='recompile all agents.', action='store_true', default=False) parser.add_argument('-m', metavar='<memlimit>', help='set memory limit [MB] (default 50 MB).', default=50, type=int) parser.add_argument('--asan', help='disables memlimit (required for ASAN binaries)', action='store_true', default=False) self.argument_values = vars(parser.parse_args())
Example 12
Project: upload-scripts Author: openstreetcam File: osc_tools.py License: MIT License | 6 votes |
def add_upload_parser(subparsers: ArgumentParser): """Adds upload parser""" upload_parser = subparsers.add_parser('upload', formatter_class=RawTextHelpFormatter) upload_parser.set_defaults(func=upload_command) upload_parser.add_argument('-p', '--path', required=True, help='Full path directory that contains sequence(s) ' 'folder(s) to upload') upload_parser.add_argument('-w', '--workers', required=False, type=int, default=10, choices=range(1, 21), metavar="[1-20]", help='Number of parallel workers used to upload files. ' 'Default number is 10.') _add_environment_argument(upload_parser) _add_logging_argument(upload_parser)
Example 13
Project: UnifiedMessageRelay Author: JQ-Networks File: daemon.py License: MIT License | 6 votes |
def main(): # ARGS argP = argparse.ArgumentParser( description="QQ <-> Telegram Bot Framework & Forwarder", formatter_class=argparse.RawTextHelpFormatter) cmdHelpStr = """ start - start bot as a daemon stop - stop bot restart - restart bot run - run as foreground Debug mode. every log will print to screen and log to file. """ argP.add_argument("command", type=str, action="store", choices=['start', 'stop', 'restart', 'run'], help=cmdHelpStr) daemon = MainProcess('/tmp/coolq-telegram-bot.pid') args = argP.parse_args() if args.command == 'start': daemon.start(debug_mode=True) elif args.command == 'stop': daemon.stop() elif args.command == 'restart': daemon.restart(debug_mode=True) elif args.command == 'run': # Run as foreground mode daemon.run(debug_mode=True)
Example 14
Project: dax Author: VUIIS File: xnat_tools_utils.py License: MIT License | 6 votes |
def parse_args(name, description, add_tools_arguments, purpose, extra_display=''): """ Method to parse arguments base on argparse :param name: name of the script :param description: description of the script for help display :param add_tools_arguments: fct to add arguments to parser :param purpose: purpose of the script :param extra_display: extra display :return: parser object """ from argparse import ArgumentParser, RawTextHelpFormatter parser = ArgumentParser(prog=name, description=description, formatter_class=RawTextHelpFormatter) parser.add_argument('--host', dest='host', default=None, help='Host for XNAT. Default: env XNAT_HOST.') parser.add_argument('-u', '--username', dest='username', default=None, help='Username for XNAT.') parser = add_tools_arguments(parser) main_display(name, purpose, extra_display) args = parser.parse_args() args_display(args) return args
Example 15
Project: skelebot Author: carsdotcom File: skeleParser.py License: MIT License | 5 votes |
def __init__(self, config=None, env=None): """Initialize the argparse Parser based on the Config data if it is present""" self.config = config self.env = env self.desc = self.buildDescription() # ---Standard Parser Setup--- # Construct the root argument parser from which all sub-parsers will be built formatter = argparse.RawTextHelpFormatter self.parser = argparse.ArgumentParser(description=self.desc, formatter_class=formatter) self.parser.add_argument(VN_ALT, VN_ARG, help=VN_HELP, action='store_true', dest=VN_DST) subparsers = self.parser.add_subparsers(dest="job") if (config.name is None): # Add SCF parser scaffoldParser = subparsers.add_parser(SCF_ARG, help=SCF_HELP) scaffoldParser.add_argument(SCF_EX_ALT, SCF_EX, action='store_true', help=SCF_EX_HELP) else: # Add STANDARD PARAMS self.parser.add_argument(ENV_ALT, ENV_ARG, help=ENV_HELP) self.parser.add_argument(SB_ALT, SB_ARG, help=SB_HELP, action='store_true', dest=SB_DST) self.parser.add_argument(NT_ALT, NT_ARG, help=NT_HELP, action='store_true', dest=NT_DST) self.parser.add_argument(CN_ALT, CN_ARG, help=CN_HELP, action='store_true', dest=CN_DST) # ---Config Based Parser Setup--- # Add JOBS if (config.jobs is not None): for job in config.jobs: subparser = subparsers.add_parser(job.name, help=job.help + " ("+job.source+")") # Add ARGS and PARAMS subparser = addArgs(job.args, subparser) subparser = addParams(job.params, subparser) subparser = addParams(config.params, subparser) # Add COMPONENT parsers for component in self.config.components: subparsers = component.addParsers(subparsers)
Example 16
Project: skelebot Author: carsdotcom File: test_components_jupyter.py License: MIT License | 5 votes |
def test_addParsers(self): jupyter = sb.components.jupyter.Jupyter(port=1127, folder="notebooks/") parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = jupyter.addParsers(subparsers) self.assertNotEqual(subparsers.choices["jupyter"], None)
Example 17
Project: skelebot Author: carsdotcom File: test_components_plugin.py License: MIT License | 5 votes |
def test_addParsers(self): plugin = sb.components.plugin.Plugin() parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = plugin.addParsers(subparsers) self.assertNotEqual(subparsers.choices["plugin"], None)
Example 18
Project: skelebot Author: carsdotcom File: test_components_artifactory.py License: MIT License | 5 votes |
def test_addParsers(self): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = self.artifactory.addParsers(subparsers) self.assertNotEqual(subparsers.choices["push"], None) self.assertNotEqual(subparsers.choices["pull"], None)
Example 19
Project: skelebot Author: carsdotcom File: test_components_repository_repository.py License: MIT License | 5 votes |
def test_addParsers_artifactory(self): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = self.artifactory.addParsers(subparsers) self.assertNotEqual(subparsers.choices["push"], None) self.assertNotEqual(subparsers.choices["pull"], None)
Example 20
Project: skelebot Author: carsdotcom File: test_components_bump.py License: MIT License | 5 votes |
def test_addParsers(self): bump = sb.components.bump.Bump() parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = bump.addParsers(subparsers) self.assertNotEqual(subparsers.choices["bump"], None)
Example 21
Project: skelebot Author: carsdotcom File: test_components_dexec.py License: MIT License | 5 votes |
def test_addParsers(self): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") dexec = sb.components.dexec.Dexec() subparsers = dexec.addParsers(subparsers) self.assertNotEqual(subparsers.choices["exec"], None)
Example 22
Project: skelebot Author: carsdotcom File: test_components_registry.py License: MIT License | 5 votes |
def test_addParsers(self): registry = sb.components.registry.Registry(host="docker.io", port=88, user="skelebot") parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="job") subparsers = registry.addParsers(subparsers) self.assertNotEqual(subparsers.choices["publish"], None)
Example 23
Project: skelebot Author: carsdotcom File: test_components_prime.py License: MIT License | 5 votes |
def test_addParsers(self): parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) subparsers = parser.add_subparsers(dest="prime") prime = sb.components.prime.Prime() subparsers = prime.addParsers(subparsers) self.assertNotEqual(subparsers.choices["prime"], None)
Example 24
Project: raspiblitz Author: rootzoll File: main.py License: MIT License | 5 votes |
def main(): # make sure CTRL+C works signal.signal(signal.SIGINT, signal.SIG_DFL) description = """BlitzTUI - the Touch-User-Interface for the RaspiBlitz project Keep on stacking SATs..! :-D""" parser = argparse.ArgumentParser(description=description, formatter_class=RawTextHelpFormatter) parser.add_argument("-V", "--version", help="print version", action="version", version=__version__) parser.add_argument('-d', '--debug', help="enable debug logging", action="store_true") # parse args args = parser.parse_args() if args.debug: setup_logging(log_level="DEBUG") else: setup_logging() log.info("Starting BlitzTUI v{}".format(__version__)) # initialize app app = QApplication(sys.argv) w = AppWindow() w.show() # run app sys.exit(app.exec_())
Example 25
Project: qutebrowser Author: qutebrowser File: hist_importer.py License: GNU General Public License v3.0 | 5 votes |
def parse(): """Parse command line arguments.""" description = ("This program is meant to extract browser history from your" " previous browser and import them into qutebrowser.") epilog = ("Databases:\n\n\tqutebrowser: Is named 'history.sqlite' and can " "be found at your --basedir. In order to find where your " "basedir is you can run ':open qute:version' inside qutebrowser." "\n\n\tFirefox: Is named 'places.sqlite', and can be found at " "your system's profile folder. Check this link for where it is " "located: http://kb.mozillazine.org/Profile_folder" "\n\n\tChrome: Is named 'History', and can be found at the " "respective User Data Directory. Check this link for where it is" "located: https://chromium.googlesource.com/chromium/src/+/" "master/docs/user_data_dir.md\n\n" "Example: hist_importer.py -b firefox -s /Firefox/Profile/" "places.sqlite -d /qutebrowser/data/history.sqlite") parser = argparse.ArgumentParser( description=description, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter ) parser.add_argument('-b', '--browser', dest='browser', required=True, type=str, help='Browsers: {firefox, chrome}') parser.add_argument('-s', '--source', dest='source', required=True, type=str, help='Source: Full path to the sqlite data' 'base file from the source browser.') parser.add_argument('-d', '--dest', dest='dest', required=True, type=str, help='\nDestination: Full path to the qutebrowser ' 'sqlite database') return parser.parse_args()
Example 26
Project: ripe-atlas-tools Author: RIPE-NCC File: base.py License: GNU General Public License v3.0 | 5 votes |
def _format_usage(self, *args): r = argparse.RawTextHelpFormatter._format_usage( self, *args).capitalize() return "\n\n{}\n".format(r)
Example 27
Project: DNA-GAN Author: Prinsphield File: vis.py License: MIT License | 5 votes |
def main(): parser = argparse.ArgumentParser(description='test', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-i', '--input', type=str, help='image path') parser.add_argument('-a', '--attributes', type=str, nargs='+', help='attribute list') parser.add_argument('--model_dir', type=str, default='train_log/model/', help='path to the model') parser.add_argument('--latent_path', type=str, default='latent', help='path to the model') parser.add_argument('-g', '--gpu', type=str, default='', help='gpu ids') args = parser.parse_args() os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu if not os.path.exists(args.latent_path): os.makedirs(args.latent_path) DNA_GAN = Model(feature_list=args.attributes, is_train=False, nhwc=[1,64,64,3]) img = np.expand_dims(misc.imresize(misc.imread(args.input), (DNA_GAN.height, DNA_GAN.width)), axis=0) get_representation(img, DNA_GAN, args.model_dir, args.latent_path)
Example 28
Project: PoseWarper Author: facebookresearch File: eval_motchallenge.py License: Apache License 2.0 | 5 votes |
def parse_args(): parser = argparse.ArgumentParser(description=""" Compute metrics for trackers using MOTChallenge ground-truth data. Files ----- All file content, ground truth and test files, have to comply with the format described in Milan, Anton, et al. "Mot16: A benchmark for multi-object tracking." arXiv preprint arXiv:1603.00831 (2016). https://motchallenge.net/ Structure --------- Layout for ground truth data <GT_ROOT>/<SEQUENCE_1>/gt/gt.txt <GT_ROOT>/<SEQUENCE_2>/gt/gt.txt ... Layout for test data <TEST_ROOT>/<SEQUENCE_1>.txt <TEST_ROOT>/<SEQUENCE_2>.txt ... Sequences of ground truth and test will be matched according to the `<SEQUENCE_X>` string.""", formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('groundtruths', type=str, help='Directory containing ground truth files.') parser.add_argument('tests', type=str, help='Directory containing tracker result files') parser.add_argument('--loglevel', type=str, help='Log level', default='info') parser.add_argument('--fmt', type=str, help='Data format', default='mot15-2D') return parser.parse_args()
Example 29
Project: toil-scripts Author: BD2KGenomics File: transfer_tcga_to_s3.py License: Apache License 2.0 | 5 votes |
def build_parser(): parser = argparse.ArgumentParser(description=main.__doc__, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-g', '--genetorrent', default=None, required=True, help='Path to a file with one analysis ID per line for data hosted on CGHub.') parser.add_argument('-k', '--genetorrent_key', default=None, required=True, help='Path to a CGHub key that has access to the TCGA data being requested. An exception will' 'be thrown if "-g" is set but not this argument.') parser.add_argument('--s3_dir', default=None, required=True, help='S3 Bucket. e.g. tcga-data') parser.add_argument('--ssec', default=None, required=True, help='Path to Key File for SSE-C Encryption') return parser # Convenience Functions
Example 30
Project: dipper Author: monarch-initiative File: add-properties2turtle.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def main(): parser = argparse.ArgumentParser( description='description', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument( '--input', '-i', type=str, required=True, help='Location of input file') parser.add_argument( '--output', '-o', type=str, required=True, help='Location of output file') parser.add_argument( '--input_format', '-f', type=str, default="turtle", help='format of source rdf file (turtle, nt, rdf/xml)') parser.add_argument( '--output_format', '-g', type=str, default="turtle", help='format of target rdf file (turtle, nt, rdf/xml)') args = parser.parse_args() property_list = get_properties_from_input(args.input, args.input_format) merged_graph = make_property_graph(property_list, args) # merge graphs merged_graph.parse(args.input, format=args.input_format) merged_graph.serialize(args.output, format=args.output_format)