def __getExceptionFromCall(func, *args, **kwargs): if not isCallable(func): return RuntimeError('First argument must be callable.') try: func(*args, **kwargs) except Exception, e: return e
def __applyFormat(self, value, formatter): """ Apply the formatter on the :param value and return the result of formatter. If the formatter is None then return the :param value unchanged. :param value: value on which to apply format. :param formatter: formatter function to apply on the value before returning the result. """ if formatter: if isCallable(formatter): return formatter(value) else: raise TypeError('formatter is not callable.') else: return value
def __applyFormat(self, value, formatter): """ Apply the formatter on the :param value and return the result of formatter. If the formatter is None then return the :param value unchanged. :param value: value on which to apply format. :param formatter: formatter function to apply on the value before returning the result. """ if formatter: if isCallable(formatter): return formatter(value) else: raise TypeError ('formatter is not callable.') else: return value