Parser
The parser interface Parser provides an object interface, where you can configure the parser to parse one or multiple configuration files. For convinience and to match the expectations for Python interfaces, there are also the methods load and loads which load and parse a configuration file using the default settings.
Usage
import erbsland.conf as elcl
try:
    doc = elcl.load("configuration.elcl")
    # ...
except elcl.Error as e:
    print(f"Failed to load configuration: {e}")
import erbsland.conf as elcl
parser = elcl.Parser()
flags = (
    elcl.AccessFeature.SAME_DIRECTORY |
    elcl.AccessFeature.SUBDIRECTORIES |
    elcl.AccessFeature.LIMIT_SIZE |
    elcl.AccessFeature.REQUIRE_SUFFIX
)
access_check = elcl.FileAccessCheck(flags)
parser.access_check = access_check
try:
    doc = parser.parse("configuration.elcl")
    # ...
except elcl.Error as e:
    print(f"Failed to load configuration: {e}")
Interface
- load(path: str | Path | Source) Document
 Parse configuration data from a file or an existing
Source.This call uses the default source resolver and access check implementations. Use an instance of
Parserto customize these implementations.- Parameters:
 path – The source to parse. This can be either a path as a string or
pathlib.Pathinstance, or an instance ofSource.- Returns:
 A
Documentinstance with the parsed configuration.- Raises:
 Error – On any error while reading and parsing the given source.
- loads(text: str) Document
 Parse configuration data from a string.
This call uses the default source resolver and access check implementations. Use an instance of
Parserto customize these implementations.
- class Parser
 Parse configuration data into
Documentobjects.- property resolver: SourceResolver
 Get or set the current source resolver. If set to
None, including files is disabled.
- property access_check: AccessCheck
 Get or set the current access check handler.
- property signature_handler: SignatureHandler
 Get or set the current signature handler.
- parse(source: Source | Path | str) Document
 Parse source into a
erbsland.conf.Document.- Parameters:
 source – The source to parse. This can be either a path as a string or
pathlib.Pathinstance, or an instance ofSource.- Returns:
 A
Documentinstance with the parsed configuration.- Raises:
 Error – On any error while reading and parsing the given source.