MCPcopy Index your code
hub / github.com/python/cpython / validate

Method validate

Lib/logging/__init__.py:489–505  ·  view source on GitHub ↗

Validate the input format, ensure it is the correct string formatting style

(self)

Source from the content-addressed store, hash-verified

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
508class StringTemplateStyle(PercentStyle):

Callers

nothing calls this directly

Calls 4

setFunction · 0.85
parseMethod · 0.45
matchMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected