SQRT Policy Parser
check
Check SQRT code syntax, raising an exception if invalid.
Parameters:
-
(sqrt_codestr) –The SQRT policy code to check.
Raises:
-
SqrtParseError–If there's a syntax error in the code.
Example
Source code in src/sequrity/sqrt/parser.py
check_file
Check SQRT file syntax, raising an exception if invalid.
Parameters:
Raises:
-
FileNotFoundError–If the file doesn't exist.
-
SqrtParseError–If there's a syntax error in the code.
Source code in src/sequrity/sqrt/parser.py
options: show_root_heading: true
validate
Validate SQRT code syntax.
A simple convenience function that returns True if the code is valid, False otherwise. Use parse() if you need error details.
Parameters:
-
(sqrt_codestr) –The SQRT policy code to validate.
Returns:
-
bool–True if the syntax is valid, False otherwise.
Example
Source code in src/sequrity/sqrt/parser.py
parse
parse(sqrt_code: str) -> ParseResult
Parse SQRT code and return the result.
This function only validates syntax. Use this to check if SQRT code is well-formed.
Parameters:
-
(sqrt_codestr) –The SQRT policy code to parse.
Returns:
-
ParseResult(ParseResult) –The result of parsing, including validity, parse tree, and any syntax error.
Example
Source code in src/sequrity/sqrt/parser.py
ParseResult
Result of parsing SQRT code.
Attributes:
-
valid(bool) –Whether the code is syntactically valid.
-
tree(Tree | None) –The parse tree if valid, None otherwise.
-
error(SqrtParseError | None) –The parse error if invalid, None otherwise.