1 from sfa.util.faults import SfaNotImplemented
2 from sfa.util.sfalogging import logger
7 This class acts as a wrapper around an SFA interface manager module, but
8 can be used with any python module. The purpose of this class is raise a
9 SfaNotImplemented exception if someone attempts to use an attribute
10 (could be a callable) thats not available in the library by checking the
11 library using hasattr. This helps to communicate better errors messages
12 to the users and developers in the event that a specifiec operation
13 is not implemented by a libarary and will generally be more helpful than
14 the standard AttributeError
16 def __init__(self, manager, interface):
17 self.manager = manager
18 self.interface = interface
20 def __getattr__(self, method):
21 if not hasattr(self.manager, method):
22 raise SfaNotImplemented(method, self.interface)
23 return getattr(self.manager, method)