Created
November 10, 2016 09:04
-
-
Save andygock/c152932833696eefcb4a92756faad665 to your computer and use it in GitHub Desktop.
Given a directory Speccy exported XML files, generate a HTML page with summary of all machines in a table format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
speccy-table.py | |
Given a directory of Speccy exported XML files, generate a HTML | |
page with summary of all machines in a table format. | |
""" | |
import xml.etree.ElementTree as ET | |
import glob | |
fields = [ 'Operating System', 'CPU', 'RAM', 'Motherboard', 'Graphics', 'Storage', 'Optical Drives', 'Audio' ] | |
print "<html><head><style type='text/css'>table{font-family:sans-serif;font-size:x-small;}</style></head><body>" | |
print "<table>" | |
print "<thead>" | |
print "<th>Machine</th>" | |
for field in fields: | |
print "<th>" + field + "</th>" | |
print "</thead>" | |
print "<tbody>" | |
files = glob.glob('./*.xml') | |
for file in files: | |
root = ET.parse(file).getroot() | |
print "<tr>" | |
print "<td>" + file + "</td>" | |
for field in fields: | |
print "<td>" | |
sections = root.findall("./mainsection/section[@title='" + field + "']/entry") | |
for s in sections: | |
print s.get('title') + "<br />" | |
print "</td>" | |
print "</tr>" | |
print "</tbody>" | |
print "</table>" | |
print "</body></html>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment