Revision 9eec6d67 lib/ht.py

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

  
48 48

  
49
class _DescWrapper(object):
49
class _WrapperBase(object):
50 50
  __slots__ = [
51 51
    "_fn",
52 52
    "_text",
......
59 59
    @param fn: Wrapped function
60 60

  
61 61
    """
62
    assert text.strip()
63

  
62 64
    self._text = text
63 65
    self._fn = fn
64 66

  
65 67
  def __call__(self, *args):
66 68
    return self._fn(*args)
67 69

  
70

  
71
class _DescWrapper(_WrapperBase):
72
  """Wrapper class for description text.
73

  
74
  """
68 75
  def __str__(self):
69 76
    return self._text
70 77

  
71 78

  
79
class _CommentWrapper(_WrapperBase):
80
  """Wrapper class for comment.
81

  
82
  """
83
  def __str__(self):
84
    return "%s [%s]" % (self._fn, self._text)
85

  
86

  
72 87
def WithDesc(text):
73 88
  """Builds wrapper class with description text.
74 89

  
......
82 97
  return compat.partial(_DescWrapper, text)
83 98

  
84 99

  
100
def Comment(text):
101
  """Builds wrapper for adding comment to description text.
102

  
103
  @type text: string
104
  @param text: Comment text
105
  @return: Callable class
106

  
107
  """
108
  assert not frozenset(text).intersection("[]")
109

  
110
  return compat.partial(_CommentWrapper, text)
111

  
112

  
85 113
def CombinationDesc(op, args, fn):
86 114
  """Build description for combinating operator.
87 115

  

Also available in: Unified diff