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


Python parser.add_argument方法代码示例

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


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

示例1: get_params_parser

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def get_params_parser():
    """Parse command line arguments"""

    parser = argparse.ArgumentParser()

    parser.add_argument("-e", "--elastic_url", default="http://127.0.0.1:9200",
                        help="Host with elastic search (default: http://127.0.0.1:9200)")
    parser.add_argument('-g', '--debug', dest='debug', action='store_true')
    parser.add_argument('-t', '--token', dest='token', help="GitHub token")
    parser.add_argument('-o', '--org', dest='org', nargs='*', help='GitHub Organization/s to be analyzed')
    parser.add_argument('-l', '--list', dest='list', action='store_true', help='Just list the repositories')
    parser.add_argument('-n', '--nrepos', dest='nrepos', type=int, default=NREPOS,
                        help='Number of GitHub repositories from the Organization to be analyzed (default:0, no limit)')
    parser.add_argument('--db-projects-map', help="Database to include the projects Mapping DB")

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

示例2: processcli

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例3: parse_args

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例4: get_params_parser

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def get_params_parser():
    """Parse command line arguments"""

    parser = argparse.ArgumentParser()

    ElasticOcean.add_params(parser)

    parser.add_argument('-g', '--debug', dest='debug', action='store_true')
    parser.add_argument('-t', '--token', dest='token', help="GitHub token")
    parser.add_argument('-o', '--org', dest='org', help='GitHub Organization to be analyzed')
    parser.add_argument('-c', '--contact', dest='contact', help='Contact (mail) to notify events.')
    parser.add_argument('--twitter', dest='twitter', help='Twitter account to notify.')
    parser.add_argument('-w', '--web-dir', default='/var/www/cauldron/dashboards', dest='web_dir',
                        help='Redirect HTML project pages for accessing Kibana dashboards.')
    parser.add_argument('-k', '--kibana-url', default='https://dashboard.cauldron.io', dest='kibana_url',
                        help='Kibana URL.')
    parser.add_argument('-u', '--graas-url', default='https://cauldron.io', dest='graas_url',
                        help='GraaS service URL.')
    parser.add_argument('-n', '--nrepos', dest='nrepos', type=int, default=NREPOS,
                        help='Number of GitHub repositories from the Organization to be analyzed (default:10)')

    return parser 
开发者ID:chaoss,项目名称:grimoirelab-elk,代码行数:24,代码来源:gh2k.py

示例5: common_args_add

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def common_args_add(parser):
    parser.add_argument('--min-age', type=int, default=0, metavar='DAYS', help='min age of requests')
    parser.add_argument('--repeat-age', type=int, default=7, metavar='DAYS', help='age after which a new reminder will be sent')
    parser.add_argument('--remind', action='store_true', help='remind maintainers to review') 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:6,代码来源:devel-project.py

示例6: argparser

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def argparser(parser=None):
	if parser is None:
		import argparse
		parser = argparse.ArgumentParser(prog="gitissuebot-approve")

	# prepare CLI argument parser
	parser.add_argument("-c", "--config", action="store", dest="config",
	                    help="The config file to use")
	parser.add_argument("-t", "--token", action="store", dest="token",
	                    help="The token to use, must be defined either on CLI or via config")
	parser.add_argument("-r", "--repo", action="store", dest="repo",
	                    help="The github repository to use, must be defined either on CLI or via config")
	parser.add_argument("-s", "--since", action="store", dest="since", type=dateutil.parser.parse,
	                    help="Only validate issues created or updated after this ISO8601 date time, defaults to now")
	parser.add_argument("--target", action="append", dest="targets", type=list,
	                    help="Target branches for PRs that must match for the PR to be considered valid")
	parser.add_argument("--notarget", action="append", dest="blacklisted_targets", type=list,
	                    help="Target branches for PRs that must not match for the PR to be considered valid")
	parser.add_argument("--source", action="append", dest="sources", type=list,
	                    help="Source branches for PRs that must match for the PR to be considered valid")
	parser.add_argument("--nosource", action="append", dest="blacklisted_sources", type=list,
	                    help="Source branches for PRs that must not match for the PR to be considered valid")
	parser.add_argument("-i", "--ignore-case", action="store_true", dest="ignore_case",
	                    help="Ignore case when matching branch names")
	parser.add_argument("--dry-run", action="store_true", dest="dryrun",
	                    help="Just print what would be done without actually doing it")
	parser.add_argument("-v", "--version", action="store_true", dest="version",
	                    help="Print the version and exit")
	parser.add_argument("--debug", action="store_true", dest="debug",
	                    help="Enable debug logging")

	return parser 
开发者ID:foosel,项目名称:GitIssueBot,代码行数:34,代码来源:prcheck.py

示例7: argparser

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def argparser(parser=None):
	if parser is None:
		import argparse
		parser = argparse.ArgumentParser(prog="gitissuebot-approve")

	def label_dict(raw):
		if not "=" in raw:
			raise argparse.ArgumentTypeError("{raw} doesn't follow the expected format '<tag>=<label>'".format(raw=raw))

		tag, label = raw.split("=", 2)
		return dict(tag=tag, label=label)

	# prepare CLI argument parser
	parser.add_argument("-c", "--config", action="store", dest="config",
	                    help="The config file to use")
	parser.add_argument("-t", "--token", action="store", dest="token",
	                    help="The token to use, must be defined either on CLI or via config")
	parser.add_argument("-r", "--repo", action="store", dest="repo",
	                    help="The github repository to use, must be defined either on CLI or via config")
	parser.add_argument("-s", "--since", action="store", dest="since", type=dateutil.parser.parse,
	                    help="Only validate issues created or updated after this ISO8601 date time, defaults to now")
	parser.add_argument("-m", "--map", action="append", dest="mappings", type=label_dict,
	                    help="Tag-label-mappings to use. Expected format is '<tag>=<label>'")
	parser.add_argument("-i", "--ignore-case", action="store_true", dest="ignore_case",
	                    help="Ignore case when matching the title snippets")
	parser.add_argument("--dry-run", action="store_true", dest="dryrun",
	                    help="Just print what would be done without actually doing it")
	parser.add_argument("-v", "--version", action="store_true", dest="version",
	                    help="Print the version and exit")
	parser.add_argument("--debug", action="store_true", dest="debug",
	                    help="Enable debug logging")

	return parser 
开发者ID:foosel,项目名称:GitIssueBot,代码行数:35,代码来源:autolabel.py

示例8: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例9: init

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [as 别名]
def init():
	parser = argparse.ArgumentParser(description="Generates a dataset by compiling generated data properties using a certain dataset model")
	parser.add_argument('--model', type=str, default='matrix', help='The name of the dataset model to use. Defaults to matrix.')
	parser.add_argument('properties', type=str, default='openPrice,closePrice,gasPrice', help='A list of the names of the properties to use, separated by a comma.')
	parser.add_argument('targets', type=str, default='highPrice', help='A list of target property names, separated by a comma.')
	parser.add_argument('--start', type=str, default=None, help='The start date. YYYY-MM-DD-HH')
	parser.add_argument('--end', type=str, default=None, help='The end date. YYYY-MM-DD-HH')
	parser.add_argument('--filename', type=str, default=None, help='The target filename / dir to save the pickled dataset to. Defaults to "data/dataset.pickle"')
	parser.add_argument('--overwrite', dest='overwrite', action='store_true', help="If the filename already exists, overwrite it.")
	parser.add_argument('--ratio', type=str, default='1', help='On how many fragments to split the main dataset. For example, "1:2:3" will create three datasets with sizes proportional to what given.')
	parser.add_argument('--shuffle', dest='shuffle', action="store_true", help="Shuffle the generated dataset and labels.")
	parser.set_defaults(shuffle=False)
	parser.set_defaults(overwrite=False)

	args, _ = parser.parse_known_args()

	if len(_) != 0:
		raise ValueError("Provided flags %s cannot be understood." % str(_))

	if args.filename == None:
		filename = "data/dataset_" + str(args.start) + "-" + str(args.end) + ".pickle"
	else: filename = args.filename

	start = args.start
	end = args.end

	start = dateutil.parser.parse(start) if start is not None else None
	end = dateutil.parser.parse(end) if end is not None else None

	try:
		ratio = [int(x) for x in args.ratio.split(':')]
	except ValueError:
		print("Error while reading the given ratio. Did you format it in the correct way?")
		return

	run(args.model, args.properties.split(','), args.targets.split(','), filename, start=start, end=end, ratio=ratio, shuffle=args.shuffle, overwrite=args.overwrite) 
开发者ID:Zvezdin,项目名称:blockchain-predictor,代码行数:38,代码来源:dataset_generator.py

示例10: survival_plot_cmdline

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例11: stack_plot_cmdline

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例12: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例13: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例14: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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

示例15: main

# 需要导入模块: from dateutil import parser [as 别名]
# 或者: from dateutil.parser import add_argument [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


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