Store argument described by, and held in, thanks to valid(), desc into the dictionary d, keyed by desc.name. Three cases: 1) desc.N is set: use args for arg value in "d", desc.instance.val only contains the last parsed arg in the "args" list 2) prefix: multiple args are joi
(desc: argdesc, args: Sequence[ValidatedArg], d: ValidatedArgs)
| 1101 | |
| 1102 | |
| 1103 | def store_arg(desc: argdesc, args: Sequence[ValidatedArg], d: ValidatedArgs): |
| 1104 | ''' |
| 1105 | Store argument described by, and held in, thanks to valid(), |
| 1106 | desc into the dictionary d, keyed by desc.name. Three cases: |
| 1107 | |
| 1108 | 1) desc.N is set: use args for arg value in "d", desc.instance.val |
| 1109 | only contains the last parsed arg in the "args" list |
| 1110 | 2) prefix: multiple args are joined with ' ' into one d{} item |
| 1111 | 3) single prefix or other arg: store as simple value |
| 1112 | |
| 1113 | Used in validate() below. |
| 1114 | ''' |
| 1115 | if desc.N: |
| 1116 | # value should be a list |
| 1117 | if desc.name in d: |
| 1118 | d[desc.name] += args |
| 1119 | else: |
| 1120 | d[desc.name] = args |
| 1121 | elif (desc.t == CephPrefix) and (desc.name in d): |
| 1122 | # prefixes' values should be a space-joined concatenation |
| 1123 | d[desc.name] += ' ' + desc.instance.val |
| 1124 | else: |
| 1125 | # did we already get this argument |
| 1126 | if desc.name in d: |
| 1127 | raise ArgumentError(f"Duplicate argument '{desc.name}' found.") |
| 1128 | # if first CephPrefix or any other type, just set it |
| 1129 | d[desc.name] = desc.instance.val |
| 1130 | |
| 1131 | |
| 1132 | def validate(args: List[str], |
no test coverage detected