当前位置: 首页>>代码示例>>Python>>正文


Python argparse.RawTextHelpFormatter方法代码示例

本文整理汇总了Python中argparse.RawTextHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python argparse.RawTextHelpFormatter方法的具体用法?Python argparse.RawTextHelpFormatter怎么用?Python argparse.RawTextHelpFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argparse的用法示例。


在下文中一共展示了argparse.RawTextHelpFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:Prinsphield,项目名称:DNA-GAN,代码行数:21,代码来源:train.py

示例2: build_parser

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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 
开发者ID:BD2KGenomics,项目名称:toil-scripts,代码行数:19,代码来源:transfer_gtex_to_s3.py

示例3: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:aetros,项目名称:aetros-cli,代码行数:22,代码来源:PredictCommand.py

示例4: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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.") 
开发者ID:aetros,项目名称:aetros-cli,代码行数:25,代码来源:IdCommand.py

示例5: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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,)) 
开发者ID:aetros,项目名称:aetros-cli,代码行数:22,代码来源:ModelCommand.py

示例6: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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)) 
开发者ID:aetros,项目名称:aetros-cli,代码行数:18,代码来源:GPUCommand.py

示例7: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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 
开发者ID:jeonghoonkang,项目名称:BerePi,代码行数:18,代码来源:save_list_2_excel.py

示例8: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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 
开发者ID:jeonghoonkang,项目名称:BerePi,代码行数:18,代码来源:save_excel_2_list.py

示例9: init_googleAssistant

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:gauravsacc,项目名称:MMM-GoogleAssistant,代码行数:21,代码来源:assistant.py

示例10: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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 
开发者ID:martisak,项目名称:3gpp-citations,代码行数:27,代码来源:standardcitations.py

示例11: __load_arguments

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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()) 
开发者ID:RUB-SysSec,项目名称:grimoire,代码行数:23,代码来源:config.py

示例12: add_upload_parser

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:openstreetcam,项目名称:upload-scripts,代码行数:22,代码来源:osc_tools.py

示例13: main

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:JQ-Networks,项目名称:UnifiedMessageRelay,代码行数:25,代码来源:daemon.py

示例14: parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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 
开发者ID:VUIIS,项目名称:dax,代码行数:26,代码来源:xnat_tools_utils.py

示例15: __init__

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawTextHelpFormatter [as 别名]
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) 
开发者ID:carsdotcom,项目名称:skelebot,代码行数:43,代码来源:skeleParser.py


注:本文中的argparse.RawTextHelpFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。