本文整理汇总了Python中docopt.docopt方法的典型用法代码示例。如果您正苦于以下问题:Python docopt.docopt方法的具体用法?Python docopt.docopt怎么用?Python docopt.docopt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docopt
的用法示例。
在下文中一共展示了docopt.docopt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def __call__(self, *args, **kwargs):
from docopt import docopt
arguments = docopt(*args, **kwargs)
from ..config import load as config_load
from ..config import ConfigFileNotFound
try:
config_load(arguments['-c'])
except ConfigFileNotFound as e:
if not arguments['config']:
puts(colored.red(str(e)))
sys.exit(1)
for patterns, function in self._functions.items():
if all(arguments[pattern] for pattern in patterns):
function(**self._kwargify(arguments))
return
raise DispatchError('None of dispatch conditions %s is triggered'
% self._formated_patterns)
示例2: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_atlas_report')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_report(arguments, tmpdir)
示例3: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(__doc__)
debug = arguments['--debug']
if debug:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_vol_result')))
ciftify.utils.log_arguments(arguments)
settings = UserSettings(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_vol_result(settings, tmpdir)
logger.info(ciftify.utils.section_header('Done ciftify_vol_result'))
sys.exit(ret)
示例4: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_statclust_report')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_report(arguments, tmpdir)
示例5: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_dlabel_to_vol')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_to_vol(arguments, tmpdir)
示例6: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
args = docopt(__doc__)
follow = args.get("--follow")
stac_file = args.get("<stac_file>")
stac_spec_dirs = args.get("--spec_dirs", None)
version = args.get("--version")
verbose = args.get("--verbose")
nthreads = args.get("--threads", 10)
timer = args.get("--timer")
log_level = args.get("--log_level", "CRITICAL")
if timer:
start = default_timer()
stac = StacValidate(stac_file, stac_spec_dirs, version, log_level, follow)
_ = stac.run(nthreads)
shutil.rmtree(stac.dirpath)
if verbose:
print(json.dumps(stac.message, indent=4))
else:
print(json.dumps(stac.status, indent=4))
if timer:
print(f"Validator took {default_timer() - start:.2f} seconds")
示例7: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
"""Run the thing."""
apply_arguments(docopt(__doc__, version=VERSION))
# print(yaml.dump(CONFIG))
initial_dir = os.getcwd()
recur_dir = os.path.abspath(os.path.expanduser(CONFIG['recur_dir']))
pkg_arg = os.path.abspath(os.path.expanduser(CONFIG['pkg_arg']))
if CONFIG['highlight']:
apply_highlight_css()
with tempfile.TemporaryDirectory() as tmpdirname:
os.chdir(tmpdirname) # genanki is very opinionated about where we are.
card_iterator = cards_from_dir(recur_dir)
cards_to_apkg(card_iterator, pkg_arg)
os.chdir(initial_dir)
示例8: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
"""Run the release."""
options = docopt(HELP)
for index, step in enumerate([ensure_not_dirty,
ensure_master,
git_pull,
ensure_passing_tests,
bump_mdk_versions,
]):
print("Step {}: {}".format(index + 1, step.__name__))
step(options)
print("""\
The release has been committed and tagged locally.
You can now push it upstream by running:
git push origin master --tags
""")
示例9: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main(args=None):
args = docopt(to_string(__doc__), args, version=__version__)
summarizer, document, items_count, reference_summary = handle_arguments(args)
evaluated_sentences = summarizer(document, items_count)
reference_document = PlaintextParser.from_string(reference_summary,
Tokenizer(args["--language"]))
reference_sentences = reference_document.document.sentences
for name, evaluate_document, evaluate in AVAILABLE_EVALUATIONS:
if evaluate_document:
result = evaluate(evaluated_sentences, document.sentences)
else:
result = evaluate(evaluated_sentences, reference_sentences)
print("%s: %f" % (name, result))
return 0
示例10: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
"""Script to load GTFS data into a database."""
args = docopt(__doc__, version=__version__)
schedule = Schedule(args['<database>'])
if args['append']:
append_feed(schedule, args['<feed_file>'],
chunk_size=int(args['--chunk-size']))
elif args['delete']:
delete_feed(schedule, args['<feed_file>'],
interactive=args['--interactive'])
elif args['overwrite']:
overwrite_feed(schedule, args['<feed_file>'],
interactive=args['--interactive'],
chunk_size=int(args['--chunk-size']))
elif args['list']:
list_feeds(schedule)
示例11: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(
__doc__,
version="gdparse {}".format(
pkg_resources.get_distribution("gdtoolkit").version
),
)
if not isinstance(arguments, dict):
print(arguments)
sys.exit(0)
for file_path in arguments["<file>"]:
with open(file_path, "r") as fh: # TODO: handle exception
content = fh.read()
tree = parser.parse(content) # TODO: handle exception
if arguments["--pretty"]:
print(tree.pretty())
elif arguments["--verbose"]:
print(tree)
示例12: setup_matcher
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def setup_matcher(args):
"""Create a new matcher objects, set parameters from docopt structure"""
matcher = audfprint_match.Matcher()
matcher.window = int(args['--match-win'])
matcher.threshcount = int(args['--min-count'])
matcher.max_returns = int(args['--max-matches'])
matcher.search_depth = int(args['--search-depth'])
matcher.sort_by_time = args['--sortbytime']
matcher.exact_count = args['--exact-count'] | args['--illustrate'] | args['--illustrate-hpf']
matcher.illustrate = args['--illustrate'] | args['--illustrate-hpf']
matcher.illustrate_hpf = args['--illustrate-hpf']
matcher.verbose = args['--verbose']
matcher.find_time_range = args['--find-time-range']
matcher.time_quantile = float(args['--time-quantile'])
return matcher
# Command to construct the reporter object
示例13: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
arguments = docopt(__doc__, version=__version__)
if not path.exists(arguments['--directory']):
sys.exit('No such directory :(')
try:
wonderful_bing = WonderfulBing(arguments)
if arguments['story']:
print(wonderful_bing.bing.picture_story)
else:
wonderful_bing.rock()
except requests.exceptions.ConnectionError:
print("ConnectionError,check your network please.")
print("Will try again after 5 minutes.")
time.sleep(300)
wonderful_bing.rock()
示例14: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
args = docopt.docopt(__doc__)
if args['secretgen']:
secretgen()
elif args['encrypt']:
encrypt(args['<secretkey>'], args['<nonce>'])
elif args['decrypt']:
decrypt(args['<secretkey>'])
elif args['signinggen']:
signinggen()
elif args['verifygen']:
verifygen(args['<signingkey>'])
elif args['keybase']:
if args['sign']:
keybase_sign(args['<signingkey>'])
elif args['verify']:
keybase_verify()
else:
if args['sign']:
sign(args['<signingkey>'])
elif args['verify']:
verify(args['<verifykey>'])
示例15: main
# 需要导入模块: import docopt [as 别名]
# 或者: from docopt import docopt [as 别名]
def main():
"""Provide an entry point into Farcy."""
args = docopt(__doc__, version='farcy v{0}'.format(__version__))
config = Config(args['REPOSITORY'], debug=args['--debug'],
exclude_paths=args['--exclude-path'],
limit_users=args['--limit-user'],
log_level=args['--logging'],
pr_issue_report_limit=args['--comments-per-pr'],
pull_requests=args['--pr'],
start_event=args['--start'])
if config.repository is None:
sys.stderr.write('No repository specified\n')
return 2
try:
Farcy(config).run()
except KeyboardInterrupt:
sys.stderr.write('Farcy shutting down. Goodbye!\n')
return 0
except FarcyException as exc:
sys.stderr.write('{0}\n'.format(exc))
return 1