Compress small text messages by just restricting the alphabet. Adds bidict.
[python_utils.git] / acl.py
diff --git a/acl.py b/acl.py
index e6bb9033f89319eb986adab2574a59171dbe899d..f810b418e635b1ca4dcbdc6df8f894764d92b8c8 100644 (file)
--- a/acl.py
+++ b/acl.py
@@ -5,7 +5,7 @@ import enum
 import fnmatch
 import logging
 import re
-from typing import Any, Callable, List, Optional, Set
+from typing import Any, Callable, List, Optional, Set, Sequence
 
 # This module is commonly used by others in here and should avoid
 # taking any unnecessary dependencies back on them.
@@ -106,7 +106,7 @@ class SetBasedACL(SimpleACL):
 
 class AllowListACL(SetBasedACL):
     """Convenience subclass for a list that only allows known items.
-    i.e. a 'whitelist'
+    i.e. a 'allowlist'
     """
     def __init__(self,
                  *,
@@ -119,7 +119,20 @@ class AllowListACL(SetBasedACL):
 
 class DenyListACL(SetBasedACL):
     """Convenience subclass for a list that only disallows known items.
-    i.e. a 'blacklist'
+    i.e. a 'blocklist'
+    """
+    def __init__(self,
+                 *,
+                 deny_set: Optional[Set[Any]]) -> None:
+        super().__init__(
+            deny_set = deny_set,
+            order_to_check_allow_deny = Order.ALLOW_DENY,
+            default_answer = True)
+
+
+class BlockListACL(SetBasedACL):
+    """Convenience subclass for a list that only disallows known items.
+    i.e. a 'blocklist'
     """
     def __init__(self,
                  *,
@@ -134,8 +147,8 @@ class PredicateListBasedACL(SimpleACL):
     """An ACL that allows or denies by applying predicates."""
     def __init__(self,
                  *,
-                 allow_predicate_list: List[Callable[[Any], bool]] = None,
-                 deny_predicate_list: List[Callable[[Any], bool]] = None,
+                 allow_predicate_list: Sequence[Callable[[Any], bool]] = None,
+                 deny_predicate_list: Sequence[Callable[[Any], bool]] = None,
                  order_to_check_allow_deny: Order,
                  default_answer: bool) -> None:
         super().__init__(