diff options
author | Jan Cholasta <jcholast@redhat.com> | 2015-06-15 12:06:47 +0000 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-07-01 13:05:30 +0000 |
commit | 1a21fd971ccc26cf8f06d1ba965b263856be56c6 (patch) | |
tree | e38be05a67287438ff824053c117e0d3be3ed1a1 /ipalib | |
parent | e9c9e3f009347d356f4d59701321888e7f00fb94 (diff) | |
download | freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.tar.gz freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.tar.xz freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.zip |
plugable: Remove SetProxy, DictProxy and MagicDict
https://fedorahosted.org/freeipa/ticket/3090
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugable.py | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 5050416b5..9e7e4fc3b 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -105,116 +105,6 @@ class Registry(object): return decorator -class SetProxy(ReadOnly): - """ - A read-only container with set/sequence behaviour. - - This container acts as a proxy to an actual set-like object (a set, - frozenset, or dict) that is passed to the constructor. To the extent - possible in Python, this underlying set-like object cannot be modified - through the SetProxy... which just means you wont do it accidentally. - """ - def __init__(self, s): - """ - :param s: The target set-like object (a set, frozenset, or dict) - """ - allowed = (set, frozenset, dict) - if type(s) not in allowed: - raise TypeError('%r not in %r' % (type(s), allowed)) - self.__s = s - if not is_production_mode(self): - lock(self) - - def __len__(self): - """ - Return the number of items in this container. - """ - return len(self.__s) - - def __iter__(self): - """ - Iterate (in ascending order) through keys. - """ - for key in sorted(self.__s): - yield key - - def __contains__(self, key): - """ - Return True if this container contains ``key``. - - :param key: The key to test for membership. - """ - return key in self.__s - - -class DictProxy(SetProxy): - """ - A read-only container with mapping behaviour. - - This container acts as a proxy to an actual mapping object (a dict) that - is passed to the constructor. To the extent possible in Python, this - underlying mapping object cannot be modified through the DictProxy... - which just means you wont do it accidentally. - - Also see `SetProxy`. - """ - def __init__(self, d): - """ - :param d: The target mapping object (a dict) - """ - if type(d) is not dict: - raise TypeError('%r is not %r' % (type(d), dict)) - self.__d = d - super(DictProxy, self).__init__(d) - - def __getitem__(self, key): - """ - Return the value corresponding to ``key``. - - :param key: The key of the value you wish to retrieve. - """ - return self.__d[key] - - def __call__(self): - """ - Iterate (in ascending order by key) through values. - """ - for key in self: - yield self.__d[key] - - -class MagicDict(DictProxy): - """ - A mapping container whose values can be accessed as attributes. - - For example: - - >>> magic = MagicDict({'the_key': 'the value'}) - >>> magic['the_key'] - 'the value' - >>> magic.the_key - 'the value' - - This container acts as a proxy to an actual mapping object (a dict) that - is passed to the constructor. To the extent possible in Python, this - underlying mapping object cannot be modified through the MagicDict... - which just means you wont do it accidentally. - - Also see `DictProxy` and `SetProxy`. - """ - - def __getattr__(self, name): - """ - Return the value corresponding to ``name``. - - :param name: The name of the attribute you wish to retrieve. - """ - try: - return self[name] - except KeyError: - raise AttributeError('no magic attribute %r' % name) - - class Plugin(ReadOnly): """ Base class for all plugins. |