aiida_vasp.utils.inheritance#

Inheritance tools.

docstring present on the base class.

Module Contents#

Functions#

update_docstring

Update docstring of (an inherited) class method.

API#

aiida_vasp.utils.inheritance.update_docstring(method_name, content, append=True)[source]#

Update docstring of (an inherited) class method.

For subclasses that use hooks to change behavior of superclass methods.

Parameters:

append – If true, append to the docstring, else overwrite it entirely.

Example:

class Base(object):
    def method(self, **kwargs):
        '''Print the base_arg kwarg.'''
        print kwargs.pop('base_arg')
        self.process_additional(**kwargs)

    def process_additional(self, **kwargs):
        pass


@update_docstring('method', '\n\nAlso print the sub_arg kwarg.', append=True)
class Subclass(Base):
    def process_additional(self, **kwargs):
        print kwargs['sub_arg']


@update_docstring('method', 'Print all kwargs.', append=False)
class Allprinter(Base):
    def process_additional(self, **kwargs):
        for _, value in kwargs.items():
            print value