diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 23:49:44 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 23:49:44 +0000 |
commit | f531f7da81864f135ff1a5f7d69e15fbe8a27210 (patch) | |
tree | 50d838f3b35d1dee017755d215f6f93b08b4e4aa /ipalib/plugable.py | |
parent | be2e323bbf3f036777acd6e5e16e03f9e66b2ee8 (diff) | |
download | freeipa-f531f7da81864f135ff1a5f7d69e15fbe8a27210.tar.gz freeipa-f531f7da81864f135ff1a5f7d69e15fbe8a27210.tar.xz freeipa-f531f7da81864f135ff1a5f7d69e15fbe8a27210.zip |
354: Added NameSpace.__todict__() method that returns copy of NameSpace.__map; updated NameSpace unit test to also test __todict__()
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index cd130a19a..e1d728d49 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -545,13 +545,13 @@ class NameSpace(ReadOnly): def __len__(self): """ - Returns the number of members. + Return the number of members. """ return len(self.__members) def __iter__(self): """ - Iterates through the member names. + Iterate through the member names. If this instance was created with ``sort=True``, the names will be in alphabetical order; otherwise the names will be in the same order as @@ -564,7 +564,7 @@ class NameSpace(ReadOnly): def __call__(self): """ - Iterates through the members. + Iterate through the members. If this instance was created with ``sort=True``, the members will be in alphabetical order by name; otherwise the members will be in the @@ -577,13 +577,13 @@ class NameSpace(ReadOnly): def __contains__(self, name): """ - Returns True if namespace has a member named ``name``. + Return True if namespace has a member named ``name``. """ return name in self.__map def __getitem__(self, spec): """ - Returns a member by name or index, or returns a slice of members. + Return a member by name or index, or returns a slice of members. :param spec: The name or index of a member, or a slice object. """ @@ -597,7 +597,7 @@ class NameSpace(ReadOnly): def __repr__(self): """ - Returns a pseudo-valid expression that could create this instance. + Return a pseudo-valid expression that could create this instance. """ return '%s(<%d members>, sort=%r)' % ( self.__class__.__name__, @@ -605,6 +605,12 @@ class NameSpace(ReadOnly): self.__sort, ) + def __todict__(self): + """ + Return a copy of the private dict mapping name to member. + """ + return dict(self.__map) + class Registrar(DictProxy): """ |