frozendict-1.2/0000775000175000017500000000000012775453706014653 5ustar slezicaslezica00000000000000frozendict-1.2/LICENSE.txt0000664000175000017500000000204312674053043016461 0ustar slezicaslezica00000000000000Copyright (c) 2012 Santiago Lezica Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. frozendict-1.2/frozendict.egg-info/0000775000175000017500000000000012775453706020514 5ustar slezicaslezica00000000000000frozendict-1.2/frozendict.egg-info/SOURCES.txt0000664000175000017500000000031212775453706022374 0ustar slezicaslezica00000000000000LICENSE.txt MANIFEST.in README.rst setup.py frozendict/__init__.py frozendict.egg-info/PKG-INFO frozendict.egg-info/SOURCES.txt frozendict.egg-info/dependency_links.txt frozendict.egg-info/top_level.txtfrozendict-1.2/frozendict.egg-info/dependency_links.txt0000664000175000017500000000000112775453706024562 0ustar slezicaslezica00000000000000 frozendict-1.2/frozendict.egg-info/PKG-INFO0000664000175000017500000000315512775453706021615 0ustar slezicaslezica00000000000000Metadata-Version: 1.0 Name: frozendict Version: 1.2 Summary: An immutable dictionary Home-page: https://github.com/slezica/python-frozendict Author: Santiago Lezica Author-email: slezica89@gmail.com License: MIT License Description: ========== frozendict ========== ``frozendict`` is an immutable wrapper around dictionaries that implements the complete mapping interface. It can be used as a drop-in replacement for dictionaries where immutability is desired. Of course, this is ``python``, and you can still poke around the object's internals if you want. The ``frozendict`` constructor mimics ``dict``, and all of the expected interfaces (``iter``, ``len``, ``repr``, ``hash``, ``getitem``) are provided. Note that a ``frozendict`` does not guarantee the immutability of its values, so the utility of ``hash`` method is restricted by usage. The only difference is that the ``copy()`` method of ``frozendict`` takes variable keyword arguments, which will be present as key/value pairs in the new, immutable copy. Example shell usage: .. code-block:: python from frozendict import frozendict fd = frozendict({ 'hello': 'World' }) print fd # print fd['hello'] # 'World' print fd.copy(another='key/value') # Platform: UNKNOWN frozendict-1.2/frozendict.egg-info/top_level.txt0000664000175000017500000000001312775453706023240 0ustar slezicaslezica00000000000000frozendict frozendict-1.2/setup.cfg0000664000175000017500000000007312775453706016474 0ustar slezicaslezica00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 frozendict-1.2/frozendict/0000775000175000017500000000000012775453706017022 5ustar slezicaslezica00000000000000frozendict-1.2/frozendict/__init__.py0000664000175000017500000000273712775453600021135 0ustar slezicaslezica00000000000000import collections import operator import functools import sys try: from collections import OrderedDict except ImportError: # python < 2.7 OrderedDict = NotImplemented iteritems = getattr(dict, 'iteritems', dict.items) # py2-3 compatibility class frozendict(collections.Mapping): """ An immutable wrapper around dictionaries that implements the complete :py:class:`collections.Mapping` interface. It can be used as a drop-in replacement for dictionaries where immutability is desired. """ dict_cls = dict def __init__(self, *args, **kwargs): self._dict = self.dict_cls(*args, **kwargs) self._hash = None def __getitem__(self, key): return self._dict[key] def __contains__(self, key): return key in self._dict def copy(self, **add_or_replace): return self.__class__(self, **add_or_replace) def __iter__(self): return iter(self._dict) def __len__(self): return len(self._dict) def __repr__(self): return '<%s %r>' % (self.__class__.__name__, self._dict) def __hash__(self): if self._hash is None: h = 0 for key, value in iteritems(self._dict): h ^= hash((key, value)) self._hash = h return self._hash class FrozenOrderedDict(frozendict): """ A frozendict subclass that maintains key order """ dict_cls = OrderedDict if OrderedDict is NotImplemented: del FrozenOrderedDict frozendict-1.2/README.rst0000664000175000017500000000212112744457535016336 0ustar slezicaslezica00000000000000========== frozendict ========== ``frozendict`` is an immutable wrapper around dictionaries that implements the complete mapping interface. It can be used as a drop-in replacement for dictionaries where immutability is desired. Of course, this is ``python``, and you can still poke around the object's internals if you want. The ``frozendict`` constructor mimics ``dict``, and all of the expected interfaces (``iter``, ``len``, ``repr``, ``hash``, ``getitem``) are provided. Note that a ``frozendict`` does not guarantee the immutability of its values, so the utility of ``hash`` method is restricted by usage. The only difference is that the ``copy()`` method of ``frozendict`` takes variable keyword arguments, which will be present as key/value pairs in the new, immutable copy. Example shell usage: .. code-block:: python from frozendict import frozendict fd = frozendict({ 'hello': 'World' }) print fd # print fd['hello'] # 'World' print fd.copy(another='key/value') # frozendict-1.2/PKG-INFO0000664000175000017500000000315512775453706015754 0ustar slezicaslezica00000000000000Metadata-Version: 1.0 Name: frozendict Version: 1.2 Summary: An immutable dictionary Home-page: https://github.com/slezica/python-frozendict Author: Santiago Lezica Author-email: slezica89@gmail.com License: MIT License Description: ========== frozendict ========== ``frozendict`` is an immutable wrapper around dictionaries that implements the complete mapping interface. It can be used as a drop-in replacement for dictionaries where immutability is desired. Of course, this is ``python``, and you can still poke around the object's internals if you want. The ``frozendict`` constructor mimics ``dict``, and all of the expected interfaces (``iter``, ``len``, ``repr``, ``hash``, ``getitem``) are provided. Note that a ``frozendict`` does not guarantee the immutability of its values, so the utility of ``hash`` method is restricted by usage. The only difference is that the ``copy()`` method of ``frozendict`` takes variable keyword arguments, which will be present as key/value pairs in the new, immutable copy. Example shell usage: .. code-block:: python from frozendict import frozendict fd = frozendict({ 'hello': 'World' }) print fd # print fd['hello'] # 'World' print fd.copy(another='key/value') # Platform: UNKNOWN frozendict-1.2/MANIFEST.in0000664000175000017500000000001612674053043016372 0ustar slezicaslezica00000000000000include *.txt frozendict-1.2/setup.py0000664000175000017500000000061412775453627016370 0ustar slezicaslezica00000000000000from setuptools import setup setup( name = 'frozendict', version = '1.2', url = 'https://github.com/slezica/python-frozendict', author = 'Santiago Lezica', author_email = 'slezica89@gmail.com', packages = ['frozendict'], license = 'MIT License', description = 'An immutable dictionary', long_description = open('README.rst').read() )