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

Method __init__

Lib/logging/__init__.py:598–623  ·  view source on GitHub ↗

Initialize the formatter with specified format strings. Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an

(self, fmt=None, datefmt=None, style='%', validate=True, *,
                 defaults=None)

Source from the content-addressed store, hash-verified

596 converter = time.localtime
597
598 def __init__(self, fmt=None, datefmt=None, style='%', validate=True, *,
599 defaults=None):
600 """
601 Initialize the formatter with specified format strings.
602
603 Initialize the formatter either with the specified format string, or a
604 default as described above. Allow for specialized date formatting with
605 the optional datefmt argument. If datefmt is omitted, you get an
606 ISO8601-like (or RFC 3339-like) format.
607
608 Use a style parameter of '%', '{' or '$' to specify that you want to
609 use one of %-formatting, :meth:`str.format` (``{}``) formatting or
610 :class:`string.Template` formatting in your format string.
611
612 .. versionchanged:: 3.2
613 Added the ``style`` parameter.
614 """
615 if style not in _STYLES:
616 raise ValueError('Style must be one of: %s' % ','.join(
617 _STYLES.keys()))
618 self._style = _STYLES[style][0](fmt, defaults=defaults)
619 if validate:
620 self._style.validate()
621
622 self._fmt = self._style._fmt
623 self.datefmt = datefmt
624
625 def __repr__(self):
626 return '<%s (%s)>' % (self.__class__.__name__, self._fmt)

Callers

nothing calls this directly

Calls 3

joinMethod · 0.45
keysMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected