Python dateutil.parser 模块,parse_args() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用dateutil.parser.parse_args()

项目:digital_rf    作者:MITHaystack    | 项目源码 | 文件源码
def parse_command_line():
    parser = optparse.OptionParser()
    parser.add_option("-v", "--verbose",action="store_true",
                       dest="verbose", default=False,help="prints debug output and additional detail.")
    parser.add_option("-d", "--debug",action="store_true",
                      dest="debug", default=False,help="run in debug mode and not service context.")
    parser.add_option("-b", "--bash",action="store_true",
                      dest="schedule", default=False,help="create schedule file for bash shell based command / control.")
    parser.add_option("-m","--mask",dest="el_mask",type=float,default=0.0,help="mask all passes below the provided elevation.")
    parser.add_option("-c", "--config",dest="config",default='config/beacons.ini',help="Use configuration file <config>.")
    parser.add_option("-f", "--foreground",action="store_true",dest="foreground",help="Execute schedule in foreground.")
    parser.add_option("-s", "--starttime",dest="starttime",help="Start time in ISO8601 format, e.g. 2016-01-01T15:24:00Z")
    parser.add_option("-e", "--endtime",dest="endtime",help="End time in ISO8601 format, e.g. 2016-01-01T16:24:00Z")
    parser.add_option("-i", "--interval",dest="interval",type=float,default=10.0,help="Sampling interval for ephemeris predictions, default is 10 seconds.")
    parser.add_option("-r", "--radio",dest="site",default='config/site.ini',help="Radio site configuration file.")

    (options, args) = parser.parse_args()

    return (options, args)
项目:dcc-metadata-indexer    作者:BD2KGenomics    | 项目源码 | 文件源码
def input_Options():
    """
    Creates the parse options
    """
    parser = argparse.ArgumentParser(description='Directory that contains Json files.')
    parser.add_argument('-d', '--test-directory', help='Directory that contains the json metadata files')
    parser.add_argument('-u', '--skip-uuid-directory', help='Directory that contains files with file uuids (bundle uuids, one per line, file ending with .redacted) that represent databundles that should be skipped, useful for redacting content (but not deleting it)')
    parser.add_argument('-m', '--metadata-schema', help='File that contains the metadata schema')
    parser.add_argument('-s', '--skip-program', help='Lets user skip certain json files that contain a specific program test')
    parser.add_argument('-o', '--only-program', help='Lets user include certain json files that contain a specific program  test')
    parser.add_argument('-r', '--skip-project', help='Lets user skip certain json files that contain a specific program test')
    parser.add_argument('-t', '--only-project', help='Lets user include certain json files that contain a specific program  test')
    parser.add_argument('-a', '--storage-access-token', default="NA", help='Storage access token to download the metadata.json files') 
    parser.add_argument('-n', '--server-host', default="redwood.io", help='hostname for the storage service')
    parser.add_argument('-p', '--max-pages', default=None, type=int, help='Specify maximum number of pages to download')
    parser.add_argument('-preserve-version',action='store_true', default=False, help='Keep all copies of analysis events')

    args = parser.parse_args()
    return args
项目:dcc-metadata-indexer    作者:BD2KGenomics    | 项目源码 | 文件源码
def input_Options():
    """
    Creates the parse options
    """
    parser = argparse.ArgumentParser(description='Directory that contains Json files.')
    parser.add_argument('-d', '--test-directory', help='Directory that contains the json metadata files')
    parser.add_argument('-u', '--skip-uuid-directory', help='Directory that contains files with file uuids (bundle uuids, one per line, file ending with .redacted) that represent databundles that should be skipped, useful for redacting content (but not deleting it)')
    parser.add_argument('-m', '--metadata-schema', help='File that contains the metadata schema')
    parser.add_argument('-s', '--skip-program', help='Lets user skip certain json files that contain a specific program test')
    parser.add_argument('-o', '--only-program', help='Lets user include certain json files that contain a specific program  test')
    parser.add_argument('-r', '--skip-project', help='Lets user skip certain json files that contain a specific program test')
    parser.add_argument('-t', '--only-project', help='Lets user include certain json files that contain a specific program  test')
    parser.add_argument('-a', '--storage-access-token', default="NA", help='Storage access token to download the metadata.json files')
    parser.add_argument('-c', '--client-path', default="ucsc-storage-client/", help='Path to access the ucsc-storage-client tool')
    parser.add_argument('-n', '--server-host', default="storage.ucsc-cgl.org", help='hostname for the storage service')
    parser.add_argument('-p', '--max-pages', default=None, type=int, help='Specify maximum number of pages to download')
    parser.add_argument('-preserve-version',action='store_true', default=False, help='Keep all copies of analysis events')

    args = parser.parse_args()
    return args
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('RefDate',help='Reference date of differential InSAR')
    parser.add_argument('-d', dest = 'date', help='date for estimation.')
    parser.add_argument('--datetxt', dest = 'datetxt', help='text file of date.')
    parser.add_argument('--Atm',action="store_true", default=False, help='Geting SAR LOS tropospheric delay.')
    parser.add_argument('--Def', action="store_true", default=False, help='Getting SAR LOS deformation.')

    inps = parser.parse_args()

    if not inps.date and not inps.datetxt:
        parser.print_usage()
        sys.exit(os.path.basename(sys.argv[0])+': error: date and date_txt File, at least one is needed.')

    return inps


####################################################################################################
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('projectName',help='Name of project.')
    parser.add_argument('--Atm',action="store_true", default=False, help='Geting SAR LOS tropospheric delay.')
    parser.add_argument('--Def', action="store_true", default=False, help='Getting SAR LOS deformation.')

    inps = parser.parse_args()


    return inps


####################################################################################################
项目:alma-slipsomat    作者:scriptotek    | 项目源码 | 文件源码
def main():
    parser = argparse.ArgumentParser()
#     parser.add_argument("-v", "--verbose", help="verbose output", action="store_true")
    parser.add_argument("-t", "--test", help="shell test, no browser", action="store_true")
    options = parser.parse_args()
    if not os.path.exists('slipsomat.cfg'):
        print('No slipsomat.cfg file found in this directory. Exiting.')
        return

    browser = Browser('slipsomat.cfg')

    if not options.test:  # test mode without driver
        browser.connect()
        atexit.register(browser.close)

    Shell(browser).cmdloop()
项目:data-bundle-examples    作者:HumanCellAtlas    | 项目源码 | 文件源码
def __init__(self):
        parser = argparse.ArgumentParser(description='Downloads data files for the various bundles.')
        parser.add_argument('--input-dir', default='.', required=True)

        # get args
        args = parser.parse_args()
        self.input_dir = args.input_dir

        # run
        self.run()
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('gps_txt',help='Available GPS station information.')
    parser.add_argument('-d', dest='time', help='SAR acquisition time.')
    parser.add_argument('--datetxt', dest='datetxt', help='text file of date for downloading.')

    inps = parser.parse_args()

    return inps


####################################################################################################
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('gps_txt',help='Available GPS station information.')
    parser.add_argument('-d', dest='time', help='SAR acquisition time.')
    parser.add_argument('--datetxt', dest='datetxt', help='text file of date for downloading.')

    inps = parser.parse_args()

    return inps


####################################################################################################
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('projectName',help='Project name.')

    inps = parser.parse_args()

    return inps


####################################################################################################
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Compare InSAR results and GPS results both for APS and deformation.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('projectName',help='Name of project.')
    parser.add_argument('--noramp',action="store_true", default=False,help='Interferograms does has no ramp.')
    parser.add_argument('--width',dest='width',help='width of unwrapped image.')

    inps = parser.parse_args()

    return inps


####################################################################################################
项目:PyGPS    作者:ymcmrs    | 项目源码 | 文件源码
def cmdLineParse():
    parser = argparse.ArgumentParser(description='Download GPS data over SAR coverage.',\
                                     formatter_class=argparse.RawTextHelpFormatter,\
                                     epilog=INTRODUCTION+'\n'+EXAMPLE)

    parser.add_argument('projectName',help='Project name.')

    inps = parser.parse_args()

    return inps


####################################################################################################
项目:quickstart-cloudera    作者:aws-quickstart    | 项目源码 | 文件源码
def main():
    parser = argparse.ArgumentParser(description='Find latest RHEL AMI')
    parser.add_argument('-v', dest="version",metavar="VERSION",required = True,
                              help='RHEL Version')
    parser.add_argument('-r', dest="region",metavar="REGION",required = True,
                              help='REGION to query AMI')
    parser.add_argument('-t', dest="type",metavar="AMI_TYPE",required = True,
                              help='AMI Type (hvm)')

    args = parser.parse_args()
    version = args.version
    region = args.region
    ami_type = args.type

    ami_name = 'RHEL-'+ version + "*" + "-x86_64*";

    cmd = aws_cmd + " ec2 describe-images --filters \"Name=name,Values=AMI-PLACEHOLDER\" \"Name=virtualization-type,Values=VTYPE-PLACEHOLDER\" --owners 309956199498 --region REGION-PLACEHOLDER"
    cmd = cmd.replace('AMI-PLACEHOLDER',ami_name)
    cmd = cmd.replace('VTYPE-PLACEHOLDER',ami_type)
    cmd = cmd.replace('REGION-PLACEHOLDER',region)

    output = exe_cmd(cmd)
    images = output['out']
    val = json.loads(images)
    images =  val['Images']
    sorted_images = sorted(images,key = get_creationdate,reverse=True)
    print sorted_images[0]['ImageId']
项目:memex-dossier-open    作者:dossier    | 项目源码 | 文件源码
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('out_dir')
    parser.add_argument('start', type=int)
    parser.add_argument('end', type=int)
    parser.add_argument('--limit', type=int)
    parser.add_argument('--skip', help='file path to URLs to skip')
    args = parser.parse_args()

    urls = make_urls(args.start, args.end, limit=args.limit, skip=args.skip)
    fetch_all(urls, args.out_dir)
项目:PenguinDome    作者:quantopian    | 项目源码 | 文件源码
def parse_args():
    parser = argparse.ArgumentParser(description='Manager Arch Linux security '
                                     'update tracking')
    parser.add_argument('--download', action='store_true',
                        help='Download new update announcemets')
    args = parser.parse_args()
    return args
项目:PenguinDome    作者:quantopian    | 项目源码 | 文件源码
def main():
    args = parse_args()

    if args.download:
        for package, dt in download_arch_security():
            flag_impacted_clients(package, dt)

    clear_obsolete_flags()
项目:yo    作者:steemit    | 项目源码 | 文件源码
def main():
    parser = argparse.ArgumentParser(description="Yo database utils")
    parser.add_argument('db_url', type=str)
    subparsers = parser.add_subparsers(help='sub-command help')
    init_sub = subparsers.add_parser('init')
    init_sub.set_defaults(func=init_db)
    reset_sub = subparsers.add_parser('reset')
    reset_sub.set_defaults(func=reset_db)
    args = parser.parse_args()
    args.func(args=args)
项目:mailnex    作者:linsam    | 项目源码 | 文件源码
def main():
    import sys
    import argparse
    parser = argparse.ArgumentParser(description="command line mail user agent")
    parser.add_argument('--config', help='custom configuration file')
    parser.add_argument('--account','-A', help='run account command after config file is read')
    args = parser.parse_args()
    interact(args)
项目:safetyculture-sdk-python    作者:SafetyCulture    | 项目源码 | 文件源码
def parse_command_line_arguments(logger):
    """
    Parse command line arguments received, if any
    Print example if invalid arguments are passed

    :param logger:  the logger
    :return:        config_filename passed as argument if any, else DEFAULT_CONFIG_FILENAME
                    export_formats passed as argument if any, else 'pdf'
                    list_export_profiles if passed as argument, else None
                    do_loop False if passed as argument, else True
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', help='config file to use, defaults to ' + DEFAULT_CONFIG_FILENAME)
    parser.add_argument('--format', nargs='*', help='formats to download, valid options are pdf, '
                                                    'json, docx, csv, media, web-report-link, actions')
    parser.add_argument('--list_export_profiles', nargs='*', help='display all export profiles, or restrict to specific'
                                                                  ' template_id if supplied as additional argument')
    parser.add_argument('--loop', nargs='*', help='execute continuously until interrupted')
    parser.add_argument('--setup', action='store_true', help='Automatically create new directory containing the '
                                                             'necessary config file.'
                        'Directory will be named iAuditor Audit Exports, and will be placed in your current directory')
    args = parser.parse_args()

    config_filename = DEFAULT_CONFIG_FILENAME

    if args.setup:
        initial_setup(logger)
        exit()

    if args.config is not None:
        if os.path.isfile(args.config):
            config_filename = args.config
            logger.debug(config_filename + ' passed as config argument')
        else:
            logger.error(config_filename + ' is not a valid config file')
            sys.exit(1)

    export_formats = ['pdf']
    if args.format is not None and len(args.format) > 0:
        valid_export_formats = ['json', 'docx', 'pdf', 'csv', 'media', 'web-report-link', 'actions']
        export_formats = []
        for option in args.format:
            if option not in valid_export_formats:
                print('{0} is not a valid export format.  Valid options are pdf, json, docx, csv, web-report-link, '
                      'media, or actions'.format(option))
                logger.info('invalid export format argument: {0}'.format(option))
            else:
                export_formats.append(option)

    loop_enabled = True if args.loop is not None else False

    return config_filename, export_formats, args.list_export_profiles, loop_enabled
项目:shiny-apps    作者:yihui    | 项目源码 | 文件源码
def parse_command_line(argv):
    me = os.path.basename(argv[0])
    format_from_filename, from_, to = filename2format(me)

    parser = argparse.ArgumentParser(description='Convert between TOML, YAML '
                                     'and JSON.')

    group = parser.add_mutually_exclusive_group()
    group.add_argument('-i', '--input', dest='input_flag', metavar='INPUT',
                       default=None, help='input file')
    group.add_argument('inputfile', nargs='?', default='-', help='input file')

    parser.add_argument('-o', '--output', dest='output', default='-',
                        help='output file')
    if not format_from_filename:
        parser.add_argument('-if', '--input-format', dest='input_format',
                            required=True, help="input format",
                            choices=FORMATS)
        parser.add_argument('-of', '--output-format', dest='output_format',
                            required=True, help="output format",
                            choices=FORMATS)
    if not format_from_filename or to == 'json':
        parser.add_argument('--indent-json', dest='indent_json',
                            action='store_const', const=2, default=None,
                            help='indent JSON output')
    if not format_from_filename or to == 'yaml':
        parser.add_argument('--yaml-style', dest='yaml_style', default=None,
                            help='YAML formatting style',
                            choices=['', '\'', '"', '|', '>'])
    parser.add_argument('--wrap', dest='wrap', default=None,
                        help='wrap the data in a map type with the given key')
    parser.add_argument('--unwrap', dest='unwrap', default=None,
                        help='only output the data stored under the given key')
    parser.add_argument('-v', '--version', action='version',
                        version=__version__)

    args = parser.parse_args(args=argv[1:])

    if args.input_flag is not None:
        args.input = args.input_flag
    else:
        args.input = args.inputfile
    if format_from_filename:
        args.input_format = from_
        args.output_format = to
        if to != 'json':
            args.__dict__['indent_json'] = None
        if to != 'yaml':
            args.__dict__['yaml_style'] = None
    args.__dict__['yaml_options'] = {'default_style': args.yaml_style}
    del args.__dict__['yaml_style']

    return args
项目:piwheels    作者:bennuttall    | 项目源码 | 文件源码
def __call__(self, args=None):
        sys.excepthook = terminal.error_handler
        parser = terminal.configure_parser("""
The piw-slave script is intended to be run on a standalone machine to build
packages on behalf of the piw-master script. It is intended to be run as an
unprivileged user with a clean home-directory. Any build dependencies you wish
to use must already be installed. The script will run until it is explicitly
terminated, either by Ctrl+C, SIGTERM, or by the remote piw-master script.
""")
        parser.add_argument(
            '-m', '--master', env_var='PIW_MASTER', metavar='HOST',
            default='localhost',
            help="The IP address or hostname of the master server "
            "(default: %(default)s)")
        parser.add_argument(
            '-t', '--timeout', env_var='PIW_TIMEOUT', metavar='DURATION',
            default='3h', type=duration,
            help="The time to wait before assuming a build has failed; "
            "(default: %(default)s)")
        self.config = parser.parse_args(args)
        terminal.configure_logging(self.config.log_level,
                                   self.config.log_file)

        self.logger.info('PiWheels Slave version %s', __version__)
        ctx = zmq.Context.instance()
        queue = ctx.socket(zmq.REQ)
        queue.hwm = 1
        queue.ipv6 = True
        queue.connect('tcp://{master}:5555'.format(
            master=self.config.master))
        try:
            request = ['HELLO', self.config.timeout,
                       pep425tags.get_impl_ver(),
                       pep425tags.get_abi_tag(),
                       pep425tags.get_platform()]
            while request is not None:
                queue.send_pyobj(request)
                reply, *args = queue.recv_pyobj()
                request = self.handle_reply(reply, *args)
        finally:
            queue.send_pyobj(['BYE'])
            ctx.destroy(linger=1000)
            ctx.term()

    # A general note about the design of the slave: the build slave is
    # deliberately designed to be "brittle". In other words to fall over and
    # die loudly in the event anything happens to go wrong (other than utterly
    # expected failures like wheels occasionally failing to build and file
    # transfers occasionally needing a retry). Hence all the apparently silly
    # asserts littering the functions below.

    # This is in stark constrast to the master which is expected to stay up and
    # carry on running even if a build slave goes bat-shit crazy and starts
    # sending nonsense (in which case it should calmly ignore it and/or attempt
    # to kill said slave with a "BYE" message).