PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/odict.py |
""" :codeauthor: Pedro Algarvio (pedro@algarvio.me) salt.utils.odict ~~~~~~~~~~~~~~~~ Implements a DefaultOrderedDict Class that serves as a combination of ``OrderedDict`` and ``defaultdict`` It's source was submitted here:: http://stackoverflow.com/questions/6190331/ """ import copy from collections import OrderedDict from collections.abc import Callable class DefaultOrderedDict(OrderedDict): """ Dictionary that remembers insertion order """ def __init__(self, default_factory=None, *a, **kw): if default_factory is not None and not isinstance(default_factory, Callable): raise TypeError("first argument must be callable") super().__init__(*a, **kw) self.default_factory = default_factory def __getitem__(self, key): try: return OrderedDict.__getitem__(self, key) except KeyError: return self.__missing__(key) def __missing__(self, key): if self.default_factory is None: raise KeyError(key) self[key] = value = self.default_factory() return value def __reduce__(self): if self.default_factory is None: args = tuple() else: args = (self.default_factory,) return type(self), args, None, None, self.items() def copy(self): return copy.copy(self) def __copy__(self): return type(self)(self.default_factory, self) def __deepcopy__(self): import copy return type(self)(self.default_factory, copy.deepcopy(self.items())) def __repr__(self, _repr_running={}): # pylint: disable=W0102 return "DefaultOrderedDict({}, {})".format( self.default_factory, super().__repr__() )