Files
iDRAC_Info/backend/check_structure.py
T
2026-05-05 17:14:11 +09:00

74 lines
2.5 KiB
Python

from html.parser import HTMLParser
class StructureValidator(HTMLParser):
def __init__(self):
super().__init__()
self.stack = []
self.important_divs = {
'fileTabsContent': None,
'processed': None,
'repository': None,
'repoTabsContent': None,
'pills-backup': None
}
def handle_starttag(self, tag, attrs):
if tag == 'div':
attr_dict = dict(attrs)
div_id = attr_dict.get('id', '')
div_class = attr_dict.get('class', '')
line_no = self.getpos()[0]
self.stack.append({
'tag': 'div',
'id': div_id,
'class': div_class,
'line': line_no
})
if div_id in self.important_divs:
self.important_divs[div_id] = {
'line': line_no,
'class': div_class,
'depth': len(self.stack)
}
def handle_endtag(self, tag):
if tag == 'div' and self.stack:
self.stack.pop()
def validate(self, html_content):
self.feed(html_content)
print("=== IMPORTANT DIV INFORMATION ===\n")
for div_id, info in self.important_divs.items():
if info:
print(f"{div_id}:")
print(f" Line: {info['line']}")
print(f" Class: {info['class']}")
print(f" Depth: {info['depth']}")
print()
# Check if processed and repository are siblings
if self.important_divs['processed'] and self.important_divs['repository']:
proc_depth = self.important_divs['processed']['depth']
repo_depth = self.important_divs['repository']['depth']
print("=== RELATIONSHIP CHECK ===")
print(f"#processed depth: {proc_depth}")
print(f"#repository depth: {repo_depth}")
if proc_depth == repo_depth:
print("✓ They are SIBLINGS (same depth) - CORRECT")
else:
print("✗ They are NOT siblings (different depth) - PROBLEM!")
print(f" Depth difference: {abs(proc_depth - repo_depth)}")
# Read the file
file_path = r"d:\Code\iDRAC_Info\idrac_info\backend\templates\index.html"
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
validator = StructureValidator()
validator.validate(content)