phml.core.formats

phml.core.formats

A collection of Formats which represent supported file formats. Each format can parse data, either string or dict, into a phml.core.nodes.AST along with compiling a phml.core.nodes.ast into it's corresponding file formats string representation.

 1"""phml.core.formats
 2
 3A collection of Formats which represent supported file formats. Each format can
 4parse data, either string or dict, into a phml.core.nodes.AST along with compiling
 5a phml.core.nodes.ast into it's corresponding file formats string representation.
 6"""
 7from __future__ import annotations
 8
 9from dataclasses import dataclass
10
11from .format import Format
12from .html_format import HTMLFormat
13from .json_format import JSONFormat
14from .phml_format import PHMLFormat
15from .xml_format import XMLFormat
16from .compile import replace_components, substitute_component, combine_component_elements, ASTRenderer
17
18
19@dataclass
20class Formats:
21    """Collection of all built-in file formats."""
22
23    PHML: Format = PHMLFormat  # pylint: disable=invalid-name
24    HTML: Format = HTMLFormat  # pylint: disable=invalid-name
25    JSON: Format = JSONFormat  # pylint: disable=invalid-name
26    XML: Format = XMLFormat  # pylint: disable=invalid-name
27
28    def __iter__(self):
29        return iter(vars(self).values())
@dataclass
class Formats:
20@dataclass
21class Formats:
22    """Collection of all built-in file formats."""
23
24    PHML: Format = PHMLFormat  # pylint: disable=invalid-name
25    HTML: Format = HTMLFormat  # pylint: disable=invalid-name
26    JSON: Format = JSONFormat  # pylint: disable=invalid-name
27    XML: Format = XMLFormat  # pylint: disable=invalid-name
28
29    def __iter__(self):
30        return iter(vars(self).values())

Collection of all built-in file formats.