Utility function to decode the flags from file name. Args: file_name: The base file name to parse. Return: Set of validated flags. Raise: TestImageException: File path is malformed.
(self, file_name: str)
| 180 | return parts[2] |
| 181 | |
| 182 | def _decode_flags(self, file_name: str) -> set[str]: |
| 183 | ''' |
| 184 | Utility function to decode the flags from file name. |
| 185 | |
| 186 | Args: |
| 187 | file_name: The base file name to parse. |
| 188 | |
| 189 | Return: |
| 190 | Set of validated flags. |
| 191 | |
| 192 | Raise: |
| 193 | TestImageException: File path is malformed. |
| 194 | ''' |
| 195 | flags: set[str] = set() |
| 196 | parts = file_name.split('-') |
| 197 | |
| 198 | # No flags specified |
| 199 | if len(parts) < 4: |
| 200 | return flags |
| 201 | |
| 202 | # ... else decode the flags field |
| 203 | raw_flags = parts[3] |
| 204 | for flag in raw_flags: |
| 205 | if flag in flags: |
| 206 | raise TestImageException(f'Duplicate flag ({flag})') |
| 207 | |
| 208 | if flag not in self.FLAGS: |
| 209 | raise TestImageException(f'Unknown flag ({flag})') |
| 210 | |
| 211 | flags.add(flag) |
| 212 | |
| 213 | return flags |
| 214 | |
| 215 | |
| 216 | class TestSet: |
no test coverage detected