@classmethod<EOL><INDENT>def _add_delegate_accessors(cls, delegate, accessors, typ,<EOL>overwrite=False):<DEDENT>
def _create_delegator_property(name):<EOL><INDENT>def _getter(self):<EOL><INDENT>return self._delegate_property_get(name)<EOL><DEDENT>def _setter(self, new_values):<EOL><INDENT>return self._delegate_property_set(name, new_values)<EOL><DEDENT>_getter.__name__ = name<EOL>_setter.__name__ = name<EOL>return property(fget=_getter, fset=_setter,<EOL>doc=getattr(delegate, name).__doc__)<EOL><DEDENT>def _create_delegator_method(name):<EOL><INDENT>def f(self, *args, **kwargs):<EOL><INDENT>return self._delegate_method(name, *args, **kwargs)<EOL><DEDENT>f.__name__ = name<EOL>f.__doc__ = getattr(delegate, name).__doc__<EOL>return f<EOL><DEDENT>for name in accessors:<EOL><INDENT>if typ == '<STR_LIT>':<EOL><INDENT>f = _create_delegator_property(name)<EOL><DEDENT>else:<EOL><INDENT>f = _create_delegator_method(name)<EOL><DEDENT>if overwrite or not hasattr(cls, name):<EOL><INDENT>setattr(cls, name, f)<EOL><DEDENT><DEDENT>
Add accessors to cls from the delegate class.

Parameters
----------
cls : the class to add the methods/properties to
delegate : the class to get methods/properties & doc-strings
accessors : string list of accessors to add
typ : 'property' or 'method'
overwrite : boolean, default False
   overwrite the method/property in the target class if it exists.