(cls, spec)
| 329 | |
| 330 | @classmethod |
| 331 | def _normalize(cls, spec): |
| 332 | if len(spec) == 1: |
| 333 | raw, = spec |
| 334 | raise NotImplementedError |
| 335 | return _resolve_column(raw) |
| 336 | |
| 337 | if len(spec) == 4: |
| 338 | label, field, width, fmt = spec |
| 339 | if width: |
| 340 | if not fmt: |
| 341 | fmt = str(width) |
| 342 | elif _parse_fmt(fmt)[0] != width: |
| 343 | raise ValueError(f'width mismatch in {spec}') |
| 344 | elif len(raw) == 3: |
| 345 | label, field, fmt = spec |
| 346 | if not field: |
| 347 | label, field = None, label |
| 348 | elif not isinstance(field, str) or not field.isidentifier(): |
| 349 | # XXX This doesn't seem right... |
| 350 | fmt = f'{field}:{fmt}' if fmt else field |
| 351 | label, field = None, label |
| 352 | elif len(raw) == 2: |
| 353 | label = None |
| 354 | field, fmt = raw |
| 355 | if not field: |
| 356 | field, fmt = fmt, None |
| 357 | elif not field.isidentifier() or fmt.isidentifier(): |
| 358 | label, field = field, fmt |
| 359 | else: |
| 360 | raise NotImplementedError |
| 361 | |
| 362 | fmt = f':{fmt}' if fmt else '' |
| 363 | if label: |
| 364 | return cls._parse(f'[{label}]{field}{fmt}') |
| 365 | else: |
| 366 | return cls._parse(f'{field}{fmt}') |
| 367 | |
| 368 | @property |
| 369 | def width(self): |
no test coverage detected