law.target.formatter#
Formatter classes for file targets.
Class FormatterRegister#
Class Formatter#
Functions#
- get_formatter(name: str, silent: bool = False) Type[Formatter] | None[source]#
Returns the formatter class whose name attribute is name. When no class could be found and silent is True, None is returned. Otherwise, an exception is raised.
- find_formatters(path: str | Path | FileSystemTarget, mode: str, silent: bool = True) list[Type[Formatter]][source]#
Returns a list of formatter classes which would accept the file given by path and mode, which should either be
"load"or"dump". When no classes could be found and silent is True, an empty list is returned. Otherwise, an exception is raised.
- find_formatter(path: str | Path | FileSystemTarget, mode: str, name: str = 'auto') Type[Formatter][source]#
Returns the formatter class whose name attribute is name when name is not AUTO_FORMATTER. Otherwise, the first formatter that accepts path is returned. Internally, this method simply uses
get_formatter()orfind_formatters()depending on the value of name.