def check_tags_exist(filepath, tag, subtag):
sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
try:
doc = ET.parse(filepath).getroot()
for event in doc.findall(tag):
if event is None:
CommonUtil.ExecLog(sModuleInfo, "%s tag is not found." % tag, 3)
else:
CommonUtil.ExecLog(sModuleInfo, "%s tag is found." % tag, 1)
for host in event.findall(subtag):
if host is None:
CommonUtil.ExecLog(sModuleInfo, "%s tag is not found." % subtag, 3)
else:
CommonUtil.ExecLog(sModuleInfo, "%s tag is found in %s." % (subtag, tag), 1)
except Exception:
errMsg = "%s - %s tag existence is not checked. " % (filepath, tag)
return CommonUtil.Exception_Handler(sys.exc_info(), None, errMsg)
xmlValidation.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录