Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_args_none():
with pytest.raises(DocoptExit):
docopt(to_string(main_doc), None, version=__version__)
def test_parse_arguments(argv, exp_res):
wg = WG()
if argv is None:
with pytest.raises(DocoptExit):
wg.parse_arguments()
assert vars(wg) == exp_res
with pytest.raises(DocoptExit):
wg.parse_arguments(argv)
assert vars(wg) == exp_res
else:
wg.parse_arguments(argv)
assert vars(wg) == exp_res
default_cmd_target=CLI_CMDTARGET.PKGALL,
default_root_dpath=storage.DCOS_INST_ROOT_DPATH_DFT,
default_config_dpath=storage.DCOS_INST_CFG_DPATH_DFT,
default_state_dpath=storage.DCOS_INST_STATE_DPATH_DFT,
default_repository_dpath=storage.DCOS_INST_PKGREPO_DPATH_DFT,
default_var_dpath=storage.DCOS_INST_VAR_DPATH_DFT,
default_clustercfg_fpath=cm_const.DCOS_CLUSTER_CFG_FNAME_DFT
)
cli_args = docopt(cli_argspec)
# Verify actual command target value
cmdtarget = cli_args.get('--target')
if cmdtarget not in VALID_CLI_CMDTARGETS:
LOG.critical(f'CLI: Invalid option value: --target: {cmdtarget}')
raise DocoptExit()
LOG.debug(f'cli_args: {cli_args}')
return cli_args
def parse_line(self, policy):
"""
Takes a single line of policy as defined in the annotations of a
pod and returns the equivalent libcalico Rule object.
:param policy: Policy string from annotations.
:return: A Rule object which represent the given policy.
"""
_log.info("Parsing policy line: '%s'", policy)
splits = policy.split()
try:
args = docopt.docopt(__doc__, argv=splits)
except docopt.DocoptExit:
raise ValueError("Failed to parse policy: %s", policy)
# Generate a rule object from the arguments.
rule = self._generate_rule(args)
return rule
raise DocoptExit(
"Input mismatch: the quantity of inputs and transcriptions differs"
)
try:
return miau(
media,
transcripts,
args['--remix'],
args['--output'],
args['--dump'],
debug=args['--debug'],
force_language=args['--lang']
)
except ValueError as e:
raise DocoptExit(str(e))
# macri_gato.mp4 macri_gato.txt
media = []
transcripts = []
for filename in chain.from_iterable(glob.iglob(pattern) for pattern in args['']):
output_extension = os.path.splitext(filename)[1][1:]
if output_extension in extensions_dict:
media.append(filename)
else:
transcripts.append(filename)
media_str = ' \n'.join(media)
transcripts_str = ' \n'.join(transcripts)
info = "Audio/Video:\n {}\nTranscripts/subtitle:\n {}".format(media_str, transcripts_str)
logging.info(info)
if not media or len(media) != len(transcripts):
raise DocoptExit(
"Input mismatch: the quantity of inputs and transcriptions differs"
)
try:
return miau(
media,
transcripts,
args['--remix'],
args['--output'],
args['--dump'],
debug=args['--debug'],
force_language=args['--lang']
)
except ValueError as e:
raise DocoptExit(str(e))
def _map_argv(argv, application_module):
try:
# by default docopt uses sys.argv[1:]; ensure correct args passed
args = docopt(__doc__, argv=argv[1:], version=application_module.__version__)
if argv[2] == "help":
raise DocoptExit()
except DocoptExit:
if argv[2] == "help":
raise
args = docopt(__doc__, argv[1:3], version=application_module.__version__)
args["--cms"] = "--cms" in argv
args["--persistent"] = "--persistent" in argv
for arg in argv:
if arg.startswith("--extra-settings="):
args["--extra-settings"] = arg.split("=")[1]
if arg.startswith("--runner="):
args["--runner"] = arg.split("=")[1]
if arg.startswith("--persistent-path="):
args["--persistent-path"] = arg.split("=")[1]
args["--persistent"] = True
args["options"] = [argv[0]] + argv[2:]
if args["test"] and "--native" in args["options"]:
Usage: bootstrap-vz [options] MANIFEST
Options:
--log
NBSP = '__'
def cmd_usage(doc):
return doc.replace(NBSP, ' ')
docopt_extras_ref = docopt.extras
def docopt_extras(help, version, options, doc):
return docopt_extras_ref(help, version, options, cmd_usage(doc))
def DocoptExit____init__(self, message=''):
SystemExit.__init__(self, (message + '\n' + cmd_usage(self.usage)).strip())
docopt.extras = docopt_extras
docopt.DocoptExit.__init__ = DocoptExit____init__
def spaced(name):
name = re.sub(r'[ _]+', r' ', name)
name = re.sub(r'(?<=[^_])([A-Z])', r' \1', name).lower()
return re.sub(r'^( *)(.*?)( *)$', r'\2', name)
class Command(object):
"""
Usage: command [...]
"""
subcommand_name = ''
argv_name = ''