(root)/
Python-3.12.0/
Lib/
importlib/
metadata/
_collections.py
       1  import collections
       2  
       3  
       4  # from jaraco.collections 3.3
       5  class ESC[4;38;5;81mFreezableDefaultDict(ESC[4;38;5;149mcollectionsESC[4;38;5;149m.ESC[4;38;5;149mdefaultdict):
       6      """
       7      Often it is desirable to prevent the mutation of
       8      a default dict after its initial construction, such
       9      as to prevent mutation during iteration.
      10  
      11      >>> dd = FreezableDefaultDict(list)
      12      >>> dd[0].append('1')
      13      >>> dd.freeze()
      14      >>> dd[1]
      15      []
      16      >>> len(dd)
      17      1
      18      """
      19  
      20      def __missing__(self, key):
      21          return getattr(self, '_frozen', super().__missing__)(key)
      22  
      23      def freeze(self):
      24          self._frozen = lambda key: self.default_factory()
      25  
      26  
      27  class ESC[4;38;5;81mPair(ESC[4;38;5;149mcollectionsESC[4;38;5;149m.ESC[4;38;5;149mnamedtuple('Pair', 'name value')):
      28      @classmethod
      29      def parse(cls, text):
      30          return cls(*map(str.strip, text.split("=", 1)))