committing uncommited work
This commit is contained in:
39
test_parse2.py
Normal file
39
test_parse2.py
Normal file
@@ -0,0 +1,39 @@
|
||||
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')
|
||||
Reference in New Issue
Block a user