drytoml.parser module¶
Additional Source to transclude tomlkit with URL and files.
-
class
drytoml.parser.
Parser
(string: str, extend_key='__extends', reference: Optional[Union[str, pathlib.Path, drytoml.types.Url]] = None, level=0)¶ Bases:
tomlkit.parser.Parser
Extend tomlkit parser to allow transclusion.
-
classmethod
factory
(reference: Union[str, drytoml.types.Url, pathlib.Path], extend_key='__extends', parent_reference: Optional[Union[str, pathlib.Path, drytoml.types.Url]] = None, level=0)¶ Instantiate a parser from url, string, or path.
- Parameters
reference – Existing file/url/path with the toml contents.
extend_key – kwarg to construct the parser.
parent_reference – Used to parse relative paths.
level – kwarg to construct the parser.
- Returns
Parser instantiated from received reference.
- Raises
ValueError – Attempted to intantiate a parser with a relative path as reference, without a parent reference.
-
classmethod
from_file
(path, extend_key='__extends', level=0)¶ Instantiate a parser from file.
- Parameters
path – Path to an existing file with the toml contents.
extend_key – kwarg to construct the parser.
level – kwarg to construct the parser.
- Returns
Parser instantiated from received path.
-
classmethod
from_url
(url, extend_key='__extends', level=0)¶ Instantiate a parser from url.
- Parameters
url – URL to an existing file with the toml contents.
extend_key – kwarg to construct the parser.
level – kwarg to construct the parser.
- Returns
Parser instantiated from received url.
-
parse
() → tomlkit.toml_document.TOMLDocument¶ Parse recursively until no transclusions are required.
- Returns
The parsed, transcluded document.
-
classmethod