def register(self, module, *args, **kwargs):
from i3pystatus.text import Text<EOL>if not module:<EOL><INDENT>return<EOL><DEDENT>hints = self.default_hints.copy() if self.default_hints else {}<EOL>hints.update(kwargs.get('<STR_LIT>', {}))<EOL>if hints:<EOL><INDENT>kwargs['<STR_LIT>'] = hints<EOL><DEDENT>try:<EOL><INDENT>return self.modules.append(module, *args, **kwargs)<EOL><DEDENT>except Exception as e:<EOL><INDENT>log.exception(e)<EOL>return self.modules.append(Text(<EOL>color="<STR_LIT>",<EOL>text="<STR_LIT>".format(<EOL>i3py_mod=module,<EOL>ex=e.__class__.__name__,<EOL>msg=e<EOL>)<EOL>))<EOL><DEDENT>
Register a new module.

:param module: Either a string module name, or a module class,
               or a module instance (in which case args and kwargs are
               invalid).
:param kwargs: Settings for the module.
:returns: module instance