From 86405236325204cb5750ce79f674a5ab01114fa7 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 12 Aug 2008 21:45:54 +0000 Subject: 119: Added ProxyTarget.implemented_by() classmethod; added corresponding unit tests --- ipalib/plugable.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ipalib/plugable.py') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index b607f0fac..a91063e7c 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -135,6 +135,18 @@ class ProxyTarget(ReadOnly): "must be str, frozenset, or have frozenset '__public__' attribute" ) + @classmethod + def implemented_by(cls, arg): + if inspect.isclass(arg): + subclass = arg + else: + subclass = arg.__class__ + assert issubclass(subclass, cls), 'must be subclass of %r' % cls + for name in cls.__public__: + if not hasattr(subclass, name): + return False + return True + class Proxy(ReadOnly): """ -- cgit