forked from edent/SuperTinyIcons
Script to update README in place (#765)
* Modified and renamed script to update README in place * Script fix and README update * Misplaced quote in table fixed * Removed old script * Readme update
This commit is contained in:
committed by
GitHub
parent
70f4abcaa0
commit
ef7c4a746e
47
update_readme.py
Normal file
47
update_readme.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
import re
|
||||
|
||||
table_length = 6
|
||||
counter = 0
|
||||
|
||||
svg_list = sorted(os.listdir('images/svg/'))
|
||||
total_bytes = 0
|
||||
|
||||
table = "<table>\n"
|
||||
for svg in svg_list:
|
||||
name = ET.parse('images/svg/'+svg).getroot().attrib["aria-label"]
|
||||
bytes = os.stat('images/svg/'+svg).st_size
|
||||
total_bytes += bytes
|
||||
|
||||
if counter == 0 :
|
||||
table += "<tr>\n"
|
||||
|
||||
table += f"<td>{name}<br>"
|
||||
table += f"<img src=\"https://edent.github.io/SuperTinyIcons/images/svg/{svg}\" width=\"100\" title=\"{name}\"><br>"
|
||||
table += f"{bytes} bytes</td>\n"
|
||||
|
||||
counter +=1
|
||||
|
||||
if counter == 6 :
|
||||
table += "</tr>\n\n"
|
||||
counter = 0
|
||||
|
||||
if counter != 0 :
|
||||
table += "</tr>\n\n"
|
||||
|
||||
table += "</table>"
|
||||
|
||||
summary_text = f"There are currently {len(svg_list)} icons and the average size is _under_ {round(total_bytes / len(svg_list))} bytes!"
|
||||
|
||||
with open('README.md','r+') as f:
|
||||
file = f.read()
|
||||
|
||||
file = re.sub(r"(?s)<table>.*?</table>", table, file)
|
||||
file = re.sub("There are currently \d* icons and the average size is _under_ \d* bytes\!", summary_text, file)
|
||||
|
||||
f.seek(0)
|
||||
f.write(file)
|
||||
f.truncate()
|
||||
|
||||
print(f"README.md updated with {len(svg_list)} icons.")
|
Reference in New Issue
Block a user