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


Python parser.parse_args方法代码示例

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


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

示例1: processcli

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def processcli():
    """
        parses the CLI arguments and returns a domain or
        a file with a list of domains.
    """
    parser = argparse.ArgumentParser(description='DNS Statistics Processor')

    parser.add_argument('--domainfile', help="Path to file with list of domains and expiration intervals.")
    parser.add_argument('--domainname', help="Domain to check expiration on.")
    parser.add_argument('--email', action="store_true", help="Enable debugging output.")
    parser.add_argument('--interactive',action="store_true", help="Enable debugging output.")
    parser.add_argument('--expiredays', default=10000, type=int, help="Expiration threshold to check against.")
    parser.add_argument('--sleeptime', default=60, type=int, help="Time to sleep between whois queries.")
    parser.add_argument('--smtpserver', default="localhost", help="SMTP server to use.")
    parser.add_argument('--smtpport', default=25, help="SMTP port to connect to.")
    parser.add_argument('--smtpto', default="root", help="SMTP To: address.")
    parser.add_argument('--smtpfrom', default="root", help="SMTP From: address.")

    # Return a dict() with all of the arguments passed in
    return(vars(parser.parse_args())) 
开发者ID:Matty9191,项目名称:dns-domain-expiration-checker,代码行数:22,代码来源:dns-domain-expiration-checker.py

示例2: parse_args

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-a",
        "--age",
        dest="age",
        type=timedelta_type,
        default="1h",
        help="Max age of a Marathon deployment before it is stopped."
        "Any pytimeparse unit is supported",
    )
    parser.add_argument(
        "-n",
        "--dry-run",
        action="store_true",
        help="Don't actually stop any Marathon deployments",
    )
    parser.add_argument("-v", "--verbose", action="store_true")
    options = parser.parse_args()
    return options 
开发者ID:Yelp,项目名称:paasta,代码行数:22,代码来源:delete_old_marathon_deployments.py

示例3: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    args = parse_args()
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.WARNING)

    clients = marathon_tools.get_list_of_marathon_clients()

    for client in clients:
        for deployment in client.list_deployments():
            delete_deployment_if_too_old(
                client=client,
                deployment=deployment,
                max_date=args.age,
                dry_run=args.dry_run,
            ) 
开发者ID:Yelp,项目名称:paasta,代码行数:19,代码来源:delete_old_marathon_deployments.py

示例4: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main(args=None):
	if args is None:
		# parse CLI arguments
		parser = argparser()
		args = parser.parse_args()

	# if only version is to be printed, do so and exit
	if args.version:
		print_version()

	# merge config (if given) and CLI parameters
	config = load_config(args.config)
	if args.token is not None:
		config["token"] = args.token
	if args.repo is not None:
		config["repo"] = args.repo
	if args.since is not None:
		config["since"] = args.since
	if args.mappings is not None:
		config["mappings"] = args.mappings
	config["ignore_case"] = config["ignore_case"] if "ignore_case" in config and config["ignore_case"] else False or args.ignore_case
	config["dryrun"] = config["dryrun"] if "dryrun" in config and config["dryrun"] else False or args.dryrun
	config["debug"] = config["debug"] if "debug" in config and config["debug"] else False or args.debug

	# validate the config
	validate_config(config)

	# setup logger
	setup_logging(debug=config["debug"])

	# process existing issues
	try:
		process_issues(config, file=args.config, dryrun=config["dryrun"])
	except:
		logger.exception("Error during execution")
		sys.exit(-1) 
开发者ID:foosel,项目名称:GitIssueBot,代码行数:38,代码来源:autolabel.py

示例5: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
  parser = argparse.ArgumentParser(description='Add NextAction labels to Todoist.')
  parser.add_argument('--api_token', required=True, help='Your API key')
  parser.add_argument('--use_priority', required=False,
      action="store_true", help='Use priority 1 rather than a label to indicate the next actions.')
  global args
  args = parser.parse_args()
  logging.basicConfig(level=logging.DEBUG)
  response = GetResponse(args.api_token)
  initial_data = response.read()
  logging.debug("Got initial data: %s", initial_data)
  initial_data = json.loads(initial_data)
  a = TodoistData(initial_data)
  while True:
    mods = a.GetProjectMods()
    if len(mods) == 0:
      time.sleep(5)
    else:
      logging.info("* Modifications necessary - skipping sleep cycle.")
    logging.info("** Beginning sync")
    sync_state = a.GetSyncState()
    changed_data = DoSyncAndGetUpdated(args.api_token,mods, sync_state).read()
    logging.debug("Got sync data %s", changed_data)
    changed_data = json.loads(changed_data)
    logging.info("* Updating model after receiving sync data")
    a.UpdateChangedData(changed_data)
    logging.info("* Finished updating model")
    logging.info("** Finished sync") 
开发者ID:akramer,项目名称:NextAction,代码行数:30,代码来源:nextaction.py

示例6: get_params

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def get_params():
    parser = get_params_parser()
    args = parser.parse_args()

    if not args.org or not args.token:
        parser.error("token and org params must be provided.")
        sys.exit(1)

    return args 
开发者ID:chaoss,项目名称:grimoirelab-elk,代码行数:11,代码来源:gh2arthur.py

示例7: survival_plot_cmdline

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def survival_plot_cmdline():
    parser = argparse.ArgumentParser(description='Plot survival plot')
    parser.add_argument('--exp-fit', action='store_true', help='Plot exponential fit')
    parser.add_argument('--display', action='store_true', help='Display plot')
    parser.add_argument('--outfile', default='survival_plot.png', type=str, help='Output file to store results (default: %(default)s)')
    parser.add_argument('--years', type=float, default=5, help='Number of years on x axis (default: %(default)s)')
    parser.add_argument('input_fns', nargs='*')
    kwargs = vars(parser.parse_args())

    survival_plot(**kwargs) 
开发者ID:erikbern,项目名称:git-of-theseus,代码行数:12,代码来源:survival_plot.py

示例8: stack_plot_cmdline

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def stack_plot_cmdline():
    parser = argparse.ArgumentParser(description='Plot stack plot')
    parser.add_argument('--display', action='store_true', help='Display plot')
    parser.add_argument('--outfile', default='stack_plot.png', type=str, help='Output file to store results (default: %(default)s)')
    parser.add_argument('--max-n', default=20, type=int, help='Max number of dataseries (will roll everything else into "other") (default: %(default)s)')
    parser.add_argument('--normalize', action='store_true', help='Normalize the plot to 100%%')
    parser.add_argument('--dont-stack', action='store_true', help='Don\'t stack plot')
    parser.add_argument('input_fn')
    kwargs = vars(parser.parse_args())

    stack_plot(**kwargs) 
开发者ID:erikbern,项目名称:git-of-theseus,代码行数:13,代码来源:stack_plot.py

示例9: get_args

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def get_args():
    parser = ArgumentParser(
        description="""Given a directory containing bulk fast5 files output a CSV containing the run 
                    information for them""",
        formatter_class=ArgumentDefaultsHelpFormatter,
        add_help=False)
    general = parser.add_argument_group(
        title='General options')
    general.add_argument("-h", "--help",
                         action="help",
                         help="Show this help and exit"
                         )
    in_args = parser.add_argument_group(
        title='Input sources'
    )
    in_args.add_argument("-d", "--dir",
                         help="A directory containing bulk-fast5-files",
                         type=str,
                         required=True,
                         metavar=''
                         )
    out_args = parser.add_argument_group(
        title='Output sources'
    )
    out_args.add_argument("-o", "--out",
                         help="Output csv filename",
                         type=str,
                         default='bulk_info.csv',
                         required=True,
                         metavar=''
                         )
    return parser.parse_args() 
开发者ID:LooseLab,项目名称:bulkvis,代码行数:34,代码来源:bulk_info.py

示例10: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    """Console script usage"""

    # Parse the input arguments and run bidscoiner(args)
    import argparse
    import textwrap
    parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
                                     description=textwrap.dedent(__doc__),
                                     epilog='examples:\n'
                                            '  bidscoiner /project/foo/raw /project/foo/bids\n'
                                            '  bidscoiner -f /project/foo/raw /project/foo/bids -p sub-009 sub-030\n ')
    parser.add_argument('sourcefolder',             help='The study root folder containing the raw data in sub-#/[ses-#/]data subfolders (or specify --subprefix and --sesprefix for different prefixes)')
    parser.add_argument('bidsfolder',               help='The destination / output folder with the bids data')
    parser.add_argument('-p','--participant_label', help='Space separated list of selected sub-# names / folders to be processed (the sub- prefix can be removed). Otherwise all subjects in the sourcefolder will be selected', nargs='+')
    parser.add_argument('-f','--force',             help='If this flag is given subjects will be processed, regardless of existing folders in the bidsfolder. Otherwise existing folders will be skipped', action='store_true')
    parser.add_argument('-s','--skip_participants', help='If this flag is given those subjects that are in participants.tsv will not be processed (also when the --force flag is given). Otherwise the participants.tsv table is ignored', action='store_true')
    parser.add_argument('-b','--bidsmap',           help='The bidsmap YAML-file with the study heuristics. If the bidsmap filename is relative (i.e. no "/" in the name) then it is assumed to be located in bidsfolder/code/bidscoin. Default: bidsmap.yaml', default='bidsmap.yaml')
    parser.add_argument('-n','--subprefix',         help="The prefix common for all the source subject-folders. Default: 'sub-'", default='sub-')
    parser.add_argument('-m','--sesprefix',         help="The prefix common for all the source session-folders. Default: 'ses-'", default='ses-')
    parser.add_argument('-v','--version',           help='Show the BIDS and BIDScoin version', action='version', version=f"BIDS-version:\t\t{bids.bidsversion()}\nBIDScoin-version:\t{bids.version()}")
    args = parser.parse_args()

    bidscoiner(rawfolder    = args.sourcefolder,
               bidsfolder   = args.bidsfolder,
               subjects     = args.participant_label,
               force        = args.force,
               participants = args.skip_participants,
               bidsmapfile  = args.bidsmap,
               subprefix    = args.subprefix,
               sesprefix    = args.sesprefix) 
开发者ID:Donders-Institute,项目名称:bidscoin,代码行数:32,代码来源:bidscoiner.py

示例11: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    global REDIS_POOL
    parser = argparse.ArgumentParser()
    parser.add_argument("--host", help="server address to listen to", default="0.0.0.0")
    parser.add_argument("--port", help="port number to listen to", default=8080, type=int)
    parser.add_argument("--redis-server", help="redis server address", default="localhost")
    parser.add_argument("--redis-port", help="redis server port", default=6379, type=int)
    args = parser.parse_args()

    REDIS_POOL = redis.ConnectionPool(host=args.redis_server, port=args.redis_port)

    http_server = WSGIServer(('', args.port), app)
    http_server.serve_forever() 
开发者ID:RedisTimeSeries,项目名称:grafana-redistimeseries,代码行数:15,代码来源:GrafanaDatastoreServer.py

示例12: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    description = "Retrieve and extract the information from Bugzilla instance"
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument(
        "--limit",
        type=int,
        help="Only download the N oldest bugs, used mainly for integration tests",
    )

    # Parse args to show the help if `--help` is passed
    args = parser.parse_args()

    retriever = Retriever()
    retriever.retrieve_bugs(args.limit) 
开发者ID:mozilla,项目名称:bugbug,代码行数:16,代码来源:bug_retriever.py

示例13: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    description = "Classify a commit"
    parser = argparse.ArgumentParser(description=description)

    parser.add_argument("model", help="Which model to use for evaluation")
    parser.add_argument(
        "repo_dir",
        help="Path to a Gecko repository. If no repository exists, it will be cloned to this location.",
    )
    parser.add_argument(
        "--phabricator-deployment",
        help="Which Phabricator deployment to hit.",
        type=str,
        choices=[PHAB_PROD, PHAB_DEV],
    )
    parser.add_argument("--diff-id", help="diff ID to analyze.", type=int)
    parser.add_argument("--revision", help="revision to analyze.", type=str)
    parser.add_argument(
        "--runnable-jobs",
        help="Path or URL to a file containing runnable jobs.",
        type=str,
    )
    parser.add_argument(
        "--git_repo_dir", help="Path where the git repository will be cloned."
    )
    parser.add_argument(
        "--method_defect_predictor_dir",
        help="Path where the git repository will be cloned.",
    )

    args = parser.parse_args()

    classifier = CommitClassifier(
        args.model, args.repo_dir, args.git_repo_dir, args.method_defect_predictor_dir
    )
    classifier.classify(
        args.revision, args.phabricator_deployment, args.diff_id, args.runnable_jobs
    ) 
开发者ID:mozilla,项目名称:bugbug,代码行数:40,代码来源:commit_classifier.py

示例14: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    description = "Retrieve and extract the test scheduling history from ActiveData"
    parser = argparse.ArgumentParser(description=description)

    parser.add_argument(
        "op", help="Which operation to perform.", choices=["retrieve", "generate"]
    )
    parser.add_argument(
        "granularity",
        help="Which test granularity to use.",
        choices=["label", "group", "config_group"],
    )
    parser.add_argument(
        "--reretrieve", type=int, default=0, help="How many results to reretrieve.",
    )
    parser.add_argument(
        "--training-months",
        type=int,
        required=True,
        help="How many months of pushes to use for training.",
    )

    args = parser.parse_args()

    retriever = Retriever()
    if args.op == "retrieve":
        retriever.generate_push_data(
            args.granularity, args.training_months, args.reretrieve
        )
    elif args.op == "generate":
        retriever.generate_test_scheduling_history(
            args.granularity, args.training_months
        ) 
开发者ID:mozilla,项目名称:bugbug,代码行数:35,代码来源:test_scheduling_history_retriever.py

示例15: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import parse_args [as 别名]
def main():
    colorama.init()
    
    parser = argparse.ArgumentParser()
    parser.add_argument('endpoint', nargs='?', default='', help="Set a " +\
        "filter on matches to retrieve (current, today, tomorrow)")
    parser.add_argument('-c', '--country', help="Filter matches to a " +\
        "specific country code.")
    parser.add_argument('-g', '--group', help="Filter matches to a " +\
        "specific group.")
    parser.add_argument('options', nargs='*', default='')
    args = parser.parse_args()

    endpoint = 'matches/' + args.endpoint
    
    if (args.country \
        or args.endpoint.lower() == 'country' and len(args.options)):
        endpoint = 'matches/country?fifa_code=%(country)s' % {
            "country": args.country.upper() if args.country \
                else args.options[0].upper() 
        }
    elif (args.group or args.endpoint.lower() == 'group' and len(args.options)):
        endpoint = 'group_results'
        group_id = int(args.group or args.options[0])
        for match in fetch(endpoint):
            if (match.get('group_id') == group_id):
                print(group_list(match))
        return

    for match in fetch(endpoint):
        print(prettify(match)) 
开发者ID:fatiherikli,项目名称:worldcup,代码行数:33,代码来源:worldcup.py


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