Files
svg2NameTag-Ren/test_parse2.py
2026-07-25 16:34:35 -04:00

40 lines
1.2 KiB
Python

from xml.dom import minidom
import glob
def analyze_format(file_path):
print(f"\nAnalyzing: {file_path}")
doc = minidom.parse(file_path)
g_tags = doc.getElementsByTagName('g')
print(f"Number of <g> tags: {len(g_tags)}")
for g in g_tags:
print(f" <g id='{g.getAttribute('id')}' class='{g.getAttribute('class')}'>")
path_tags = doc.getElementsByTagName('path')
print(f"Number of <path> tags: {len(path_tags)}")
bg_paths = 0
white_paths = 0
cyan_paths = 0
unknown_paths = 0
for p in path_tags:
parent = p.parentNode
parent_id = parent.getAttribute('id') if parent else ""
if parent_id == "background":
bg_paths += 1
elif parent_id == "white-text":
white_paths += 1
elif parent_id == "cyan-logo-text":
cyan_paths += 1
else:
unknown_paths += 1
print(f"Path distribution by <g> id:")
print(f" background: {bg_paths}")
print(f" white-text: {white_paths}")
print(f" cyan-logo-text: {cyan_paths}")
print(f" unknown/no-group: {unknown_paths}")
analyze_format(r'S:\svg2nametagCLI\new\SammieWyles_nametag.svg')