Revision 7fc548e9

b/lib/ht.py
45 45
    return "(%s)" % text
46 46

  
47 47

  
48
class _DescWrapper(object):
49
  __slots__ = [
50
    "_fn",
51
    "_text",
52
    ]
53

  
54
  def __init__(self, text, fn):
55
    """Initializes this class.
56

  
57
    @param text: Description
58
    @param fn: Wrapped function
59

  
60
    """
61
    self._text = text
62
    self._fn = fn
63

  
64
  def __call__(self, *args):
65
    return self._fn(*args)
66

  
67
  def __str__(self):
68
    return self._text
69

  
70

  
48 71
def WithDesc(text):
49 72
  """Builds wrapper class with description text.
50 73

  
......
55 78
  """
56 79
  assert text[0] == text[0].upper()
57 80

  
58
  class wrapper(object): # pylint: disable-msg=C0103
59
    __slots__ = ["__call__"]
60

  
61
    def __init__(self, fn):
62
      """Initializes this class.
63

  
64
      @param fn: Wrapped function
65

  
66
      """
67
      self.__call__ = fn
68

  
69
    def __str__(self):
70
      return text
71

  
72
  return wrapper
81
  return compat.partial(_DescWrapper, text)
73 82

  
74 83

  
75 84
def CombinationDesc(op, args, fn):

Also available in: Unified diff