16 from itertools
import chain
21 from .stats
import CombinedTagStat, CriticalTagStat, TagStat
22 from .tags
import SingleTagPattern, TagPatterns
28 def __init__(self, critical_stats, non_critical_stats, combined_stats):
31 self.
tagstags = NormalizedDict(ignore=
'_')
40 visitor.visit_tag_statistics(self)
44 tags = [t
for t
in self.
tagstags.values()
if t.name
not in crits]
50 if isinstance(stat.pattern, SingleTagPattern)]
51 return NormalizedDict([(
unicode(stat.pattern),
None)
for stat
in crits],
57 def __init__(self, criticality=None, included=None, excluded=None,
58 combined=None, docs=None, links=None):
63 self.
_info_info.get_critical_stats(criticality),
64 self.
_info_info.get_critical_stats(criticality, critical=
False),
65 self.
_info_info.get_combined_stats(combined)
75 if tag
not in self.
statsstats.tags:
76 self.
statsstats.tags[tag] = self.
_info_info.get_stat(tag)
82 return not self.
_excluded_excluded.match(tag)
85 stats = self.
statsstats
86 for stat
in stats.critical + stats.non_critical + stats.combined:
87 if stat.match(test.tags):
103 tag_patterns = (criticality.critical_tags
104 if critical
else criticality.non_critical_tags)
116 name = name
or pattern
121 return ' & '.join(doc.text
for doc
in self.
_docs_docs
if doc.match(tag))
124 return [link.get_link(tag)
for link
in self.
_links_links
if link.match(tag)]
141 _match_pattern_tokenizer = re.compile(
'(\*|\?+)')
146 self.
_title_title = title.replace(
'_',
' ')
159 for index, group
in enumerate(match.groups()):
160 placefolder =
'%%%d' % (index+1)
161 link = link.replace(placefolder, group)
162 title = title.replace(placefolder, group)
167 return re.compile(pattern, re.IGNORECASE)
171 if token.startswith(
'?'):
172 yield '(%s)' % (
'.'*len(token))
176 yield re.escape(token)
unicode
Exceptions and return codes used internally.