def uses_tags(self):
members = inspect.getmembers(self, predicate=inspect.ismethod)
handles = [member for member in members if member[0].startswith("handle_") or member[0] == 'preprocess']
alltags = set([])
for handle in handles:
if handle[0].startswith("handle_"):
alltags.add(handle[0][len("handle_"):])
doc = handle[1].__doc__
if not doc:
continue
for line in doc.splitlines():
m = re.search(r"Uses tags:(.+)", line)
if m:
tags = m.group(1).split(",")
tags = [tag.strip() for tag in tags]
alltags.update(tags)
alltags.update(self.enumerateable_envs.keys())
return alltags
评论列表
文章目录