Validate the input format, ensure it is the correct string formatting style
(self)
| 487 | return self._fmt.format(**values) |
| 488 | |
| 489 | def validate(self): |
| 490 | """Validate the input format, ensure it is the correct string formatting style""" |
| 491 | fields = set() |
| 492 | try: |
| 493 | for _, fieldname, spec, conversion in _str_formatter.parse(self._fmt): |
| 494 | if fieldname: |
| 495 | if not self.field_spec.match(fieldname): |
| 496 | raise ValueError('invalid field name/expression: %r' % fieldname) |
| 497 | fields.add(fieldname) |
| 498 | if conversion and conversion not in 'rsa': |
| 499 | raise ValueError('invalid conversion: %r' % conversion) |
| 500 | if spec and not self.fmt_spec.match(spec): |
| 501 | raise ValueError('bad specifier: %r' % spec) |
| 502 | except ValueError as e: |
| 503 | raise ValueError('invalid format: %s' % e) |
| 504 | if not fields: |
| 505 | raise ValueError('invalid format: no fields') |
| 506 | |
| 507 | |
| 508 | class StringTemplateStyle(PercentStyle): |