about summary refs log tree commit diff
path: root/gn_libs/privileges.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn_libs/privileges.py')
-rw-r--r--gn_libs/privileges.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/gn_libs/privileges.py b/gn_libs/privileges.py
index 47cb735..a515970 100644
--- a/gn_libs/privileges.py
+++ b/gn_libs/privileges.py
@@ -1,11 +1,13 @@
 """Utilities for handling privileges."""
-from typing import Union, TypeAlias
+from typing import Union, Sequence, TypeAlias
 
-PrivilegesList = tuple[str, ...]
-CheckObj = tuple[str, PrivilegesList] # where the first item is either "OR" or "AND"
-Checks: TypeAlias = Union[
-    CheckObj,
-    tuple[str, tuple['Checks', ...]]]
+Operator: TypeAlias = str # Valid operators: "AND", "OR"
+Privilege: TypeAlias = str
+PrivilegesList: TypeAlias = Sequence[Privilege]
+ParseTree = tuple[Operator,
+                  # Leaves (`PrivilegesList` objects) on the left,
+                  # trees (`ParseTree` objects) on the right
+                  Union[PrivilegesList, tuple[PrivilegesList, 'ParseTree']]]
 
 
 class SpecificationValueError(ValueError):
@@ -13,7 +15,7 @@ class SpecificationValueError(ValueError):
     pass
 
 
-def parse(spec: str) -> Checks:
+def parse(spec: str) -> ParseTree:
     """Parse a string specification for privileges and return a tree of data
     objects of the form (<operator> (<check>))"""
     # if(spec.strip() == ""):