def _parseTagRecursive(self, candi_tag, template_tag, template_var_cache):
for idx, tmpChild in enumerate(template_tag.contents):
if tmpChild.name == 'lisp_pass':
# this means <...>,
# indicating that anything in this tag is expected to be ignored.
continue
if len(candi_tag.contents) <= idx:
return False
candiChild = candi_tag.contents[idx]
typeCandi = type(candiChild)
typeTmp = type(tmpChild)
valid = False
if typeCandi == typeTmp == element.Tag:
if self._censorTagCandidateWithTemplate(candiChild, tmpChild, template_var_cache):
valid = self._parseTagRecursive(candiChild, tmpChild, template_var_cache)
elif typeCandi == typeTmp == element.NavigableString:
valid = self._censorNaviStrCandidateWithTemplate(
candiChild, tmpChild, template_var_cache)
if valid is False and len(template_var_cache) > 0:
self.logger.warning(template_tag)
self.logger.warning(candi_tag)
self.logger.warning('censor not passed. cache will be cleared')
template_var_cache.clear()
return False
return True
评论列表
文章目录