1717
1818class Stat (object ):
1919
20- def __init__ (self , name = '' ):
20+ def __init__ (self , name ):
2121 self .name = name
2222 self .passed = 0
2323 self .failed = 0
2424
2525 @property
26- def _default_attrs (self ):
27- return {'pass' : str (self .passed ), 'fail' : str (self .failed )}
26+ def attrs (self ):
27+ attrs = {'pass' : str (self .passed ), 'fail' : str (self .failed )}
28+ attrs .update (self ._get_custom_attrs ())
29+ return attrs
30+
31+ def _get_custom_attrs (self ):
32+ return {}
2833
2934 @property
3035 def total (self ):
@@ -46,7 +51,7 @@ def __cmp__(self, other):
4651 return cmp (self .name , other .name )
4752
4853 def __nonzero__ (self ):
49- return self .failed == 0
54+ return not self .failed
5055
5156 def visit (self , visitor ):
5257 visitor .visit_stat (self )
@@ -58,11 +63,10 @@ class SuiteStat(Stat):
5863 def __init__ (self , suite ):
5964 Stat .__init__ (self , suite .longname )
6065 self .id = suite .id
61- self ._attrs = { 'name' : suite .name , 'idx' : suite . id }
66+ self ._name = suite .name
6267
63- @property
64- def attrs (self ):
65- return dict (self ._default_attrs , ** self ._attrs ) # TODO: idx -> id
68+ def _get_custom_attrs (self ):
69+ return {'idx' : self .id , 'name' : self ._name } # TODO: isx -> id
6670
6771
6872class TagStat (Stat ):
@@ -71,20 +75,14 @@ class TagStat(Stat):
7175 def __init__ (self , name , doc = '' , links = None , critical = False ,
7276 non_critical = False , combined = '' ):
7377 Stat .__init__ (self , name )
74- # TODO: Do we need all these attrs or could they me only in self.attrs?
7578 self .doc = doc
76- self .links = links or [] # TODO: Are both self.links and self._link_str needed?
79+ self .links = links
7780 self .critical = critical
7881 self .non_critical = non_critical
7982 self .combined = combined
8083
8184 @property
82- def attrs (self ):
83- return dict (self ._default_attrs , info = self ._info , links = self ._link_str ,
84- doc = self .doc , combined = self .combined )
85-
86- @property
87- def _info (self ):
85+ def info (self ):
8886 if self .critical :
8987 return 'critical'
9088 if self .non_critical :
@@ -93,9 +91,12 @@ def _info(self):
9391 return 'combined'
9492 return ''
9593
96- @property
97- def _link_str (self ):
98- return ':::' .join (':' .join ([title , url ]) for url , title in self .links )
94+ def _get_custom_attrs (self ):
95+ return {'doc' : self .doc , 'links' : self ._get_links_as_string (),
96+ 'info' : self .info , 'combined' : self .combined }
97+
98+ def _get_links_as_string (self ):
99+ return ':::' .join ('%s:%s' % (title , url ) for url , title in self .links )
99100
100101 def __cmp__ (self , other ):
101102 return cmp (other .critical , self .critical ) \
@@ -121,7 +122,3 @@ def __init__(self, name, suite_stat):
121122 Stat .__init__ (self , name )
122123 self .passed = suite_stat .passed
123124 self .failed = suite_stat .failed
124-
125- @property
126- def attrs (self ):
127- return self ._default_attrs
0 commit comments