def __call__(self, parent_class, meth):
key = (parent_class, meth.__name__)
if key not in self.memoized:
parent_module = self.get_parent_module(parent_class)
module_tags = getattr(parent_module, '__tags__', [])
class_tags = getattr(parent_class, '__tags__', [])
tags = TAGS_RE.search(inspect.getdoc(meth) or '')
if tags: test_tags = [t.strip() for t in tags.group(1).split(',')]
else: test_tags = []
combined = set()
for tags in (module_tags, class_tags, test_tags):
if not tags: continue
add = set([t for t in tags if not t.startswith('-')])
remove = set([t[1:] for t in tags if t not in add])
if add: combined.update(add)
if remove: combined.difference_update(remove)
self.memoized[key] = combined
return self.memoized[key]
评论列表
文章目录