about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py
diff options
context:
space:
mode:
Diffstat (limited to '.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py')
-rw-r--r--.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py b/.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py
new file mode 100644
index 00000000..20cbd1c4
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/openpyxl/utils/bound_dictionary.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2010-2024 openpyxl
+
+from collections import defaultdict
+
+
+class BoundDictionary(defaultdict):
+    """
+    A default dictionary where elements are tightly coupled.
+
+    The factory method is responsible for binding the parent object to the child.
+
+    If a reference attribute is assigned then child objects will have the key assigned to this.
+
+    Otherwise it's just a defaultdict.
+    """
+
+    def __init__(self, reference=None, *args, **kw):
+        self.reference = reference
+        super().__init__(*args, **kw)
+
+
+    def __getitem__(self, key):
+        value = super().__getitem__(key)
+        if self.reference is not None:
+            setattr(value, self.reference, key)
+        return value