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)
| 1023 | ArgValT = Union[bool, int, float, str, Tuple[str, str]] |
| 1024 | |
| 1025 | def 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 | |
| 1053 | def matchnum(args: List[str], |