Пример #1
0
 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        
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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