diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-01 01:47:49 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-01 01:47:49 +0000 |
commit | f53dec2600f95246a72fa3c847a485d2a94edfa7 (patch) | |
tree | b95235cb5babe2de1cc72c49509de422aba72d8b /ipalib/plugable.py | |
parent | a131ebf72469d416d4c08e23a7f3ac70854b237b (diff) | |
download | freeipa.git-f53dec2600f95246a72fa3c847a485d2a94edfa7.tar.gz freeipa.git-f53dec2600f95246a72fa3c847a485d2a94edfa7.tar.xz freeipa.git-f53dec2600f95246a72fa3c847a485d2a94edfa7.zip |
33: Finished unit tests for plugable.Proxy
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 054b12db..de5f3f8f 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -27,10 +27,19 @@ import errors def to_cli(name): - assert isinstance(name, basestring) + """ + Takes a Python identifier and transforms it into form suitable for the + Command Line Interface. + """ + assert isinstance(name, str) return name.replace('__', '.').replace('_', '-') + def from_cli(cli_name): + """ + Takes a string from the Command Line Interface and transforms it into a + Python identifier. + """ assert isinstance(cli_name, basestring) return cli_name.replace('-', '_').replace('.', '__') @@ -69,7 +78,6 @@ class Proxy(object): __slots__ = ( '__obj', 'name', - 'cli_name', ) def __init__(self, obj, proxy_name=None): @@ -77,11 +85,10 @@ class Proxy(object): Proxy attributes on `obj`. """ if proxy_name is None: - proxy_name = obj.name + proxy_name = obj.__class__.__name__ assert isinstance(proxy_name, str) object.__setattr__(self, '_Proxy__obj', obj) object.__setattr__(self, 'name', proxy_name) - object.__setattr__(self, 'cli_name', to_cli(proxy_name)) for name in self.__slots__: object.__setattr__(self, name, getattr(obj, name)) @@ -107,7 +114,7 @@ class Proxy(object): return '%s(%r)' % (self.__class__.__name__, self.__obj) def __str__(self): - return self.cli_name + return to_cli(self.name) class Registrar(object): |