MCPcopy Create free account
hub / github.com/ceph/ceph / validate_one

Function validate_one

src/pybind/ceph_argparse.py:1025–1050  ·  view source on GitHub ↗

validate_one(word, desc, is_kwarg, partial=False) validate word against the constructed instance of the type in desc. May raise exception. If it returns false (and doesn't raise an exception), desc.instance.val will contain the validated value (in the appropriate type).

(word: str,
                 desc,
                 is_kwarg: bool,
                 partial: bool = False)

Source from the content-addressed store, hash-verified

1023ArgValT = Union[bool, int, float, str, Tuple[str, str]]
1024
1025def validate_one(word: str,
1026 desc,
1027 is_kwarg: bool,
1028 partial: bool = False) -> List[ArgValT]:
1029 """
1030 validate_one(word, desc, is_kwarg, partial=False)
1031
1032 validate word against the constructed instance of the type
1033 in desc. May raise exception. If it returns false (and doesn't
1034 raise an exception), desc.instance.val will
1035 contain the validated value (in the appropriate type).
1036 """
1037 vals = []
1038 # CephString option might contain "," in it
1039 allow_csv = is_kwarg or desc.t is not CephString
1040 if desc.N and allow_csv:
1041 for part in word.split(','):
1042 desc.instance.valid(part, partial)
1043 vals.append(desc.instance.val)
1044 else:
1045 desc.instance.valid(word, partial)
1046 vals.append(desc.instance.val)
1047 desc.numseen += 1
1048 if desc.N:
1049 desc.n = desc.numseen + 1
1050 return vals
1051
1052
1053def matchnum(args: List[str],

Callers 3

matchnumFunction · 0.85
validateFunction · 0.85
validateMethod · 0.85

Calls 3

splitMethod · 0.45
validMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected