MCPcopy Create free account
hub / github.com/espnet/espnet / check_required_command_args

Method check_required_command_args

espnet2/tasks/abs_task.py:1197–1215  ·  view source on GitHub ↗
(cls, args: argparse.Namespace)

Source from the content-addressed store, hash-verified

1195 @classmethod
1196 @typechecked
1197 def check_required_command_args(cls, args: argparse.Namespace):
1198 for k in vars(args):
1199 if "-" in k:
1200 raise RuntimeError(f'Use "_" instead of "-": parser.get_parser("{k}")')
1201
1202 required = ", ".join(
1203 f"--{a}" for a in args.required if getattr(args, a) is None
1204 )
1205
1206 if len(required) != 0:
1207 parser = cls.get_parser()
1208 parser.print_help(file=sys.stderr)
1209 p = Path(sys.argv[0]).name
1210 print(file=sys.stderr)
1211 print(
1212 f"{p}: error: the following arguments are required: " f"{required}",
1213 file=sys.stderr,
1214 )
1215 sys.exit(2)
1216
1217 @classmethod
1218 @typechecked

Callers 1

mainMethod · 0.80

Calls 1

get_parserMethod · 0.45

Tested by

no test coverage detected