Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/openpyxl/utils/bound_dictionary.py : 40%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) 2010-2020 openpyxl
3from collections import defaultdict
6class BoundDictionary(defaultdict):
7 """
8 A default dictionary where elements are tightly coupled.
10 The factory method is responsible for binding the parent object to the child.
12 If a reference attribute is assigned then child objects will have the key assigned to this.
14 Otherwise it's just a defaultdict.
15 """
17 def __init__(self, reference=None, *args, **kw):
18 self.reference = reference
19 super(BoundDictionary, self).__init__(*args, **kw)
22 def __getitem__(self, key):
23 value = super(BoundDictionary, self).__getitem__(key)
24 if self.reference is not None:
25 setattr(value, self.reference, key)
26 return value