nvflare.fuel.hci.cmd_arg_utils module

class ArgValidator(name)[source]

Bases: ArgumentParser

Validator for admin shell commands that uses argparse to check arguments and get usage through print_help.

Parameters:

name – name of the program to pass to ArgumentParser

error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

get_usage() str[source]
validate(args)[source]
get_file_extension(file: str) str[source]

Get extension part of the specified file name. If the file’s name is ended with number, then the extension is before it.

Parameters:

file – the file name

Returns: extension part of the file name

join_args(segs: List[str]) str[source]
parse_command_line(line: str) -> (<class 'str'>, typing.List[str], <class 'str'>)[source]

Parse the command line and extract command args and command props, if any

Parameters:

line

Returns:

process_targets_into_str(targets: List[str]) str[source]
split_to_args(line: str) List[str][source]
validate_file_string(file: str) str[source]

Returns the file string if it is valid.

validate_options_string(options: str) str[source]

Returns the options string if it is valid.

validate_path_string(path: str) str[source]

Returns the path string if it is valid.

validate_required_target_string(target: str) str[source]

Returns the target string if it exists and is valid.

validate_sp_string(sp_string) str[source]
validate_text_file_name(file_name: str) str[source]

Check the specified file name whether it is acceptable.

Parameters:

file_name – file name to be checked.

Returns: error string if invalid; or empty string if valid