(cls, specstr)
| 297 | |
| 298 | @classmethod |
| 299 | def _parse(cls, specstr): |
| 300 | m = cls.REGEX.match(specstr) |
| 301 | if not m: |
| 302 | return None |
| 303 | (label, field, |
| 304 | align, width1, |
| 305 | width2, fmt, |
| 306 | ) = m.groups() |
| 307 | if not label: |
| 308 | label = field |
| 309 | if fmt: |
| 310 | assert not align and not width1, (specstr,) |
| 311 | _parsed = _parse_fmt(fmt) |
| 312 | if not _parsed: |
| 313 | raise NotImplementedError |
| 314 | elif width2: |
| 315 | width, _ = _parsed |
| 316 | if width != int(width2): |
| 317 | raise NotImplementedError(specstr) |
| 318 | elif width2: |
| 319 | fmt = width2 |
| 320 | width = int(width2) |
| 321 | else: |
| 322 | assert not fmt, (fmt, specstr) |
| 323 | if align: |
| 324 | width = int(width1) if width1 else len(label) |
| 325 | fmt = f'{align}{width}' |
| 326 | else: |
| 327 | width = None |
| 328 | return field, label, fmt, width |
| 329 | |
| 330 | @classmethod |
| 331 | def _normalize(cls, spec): |
no test coverage detected