diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbafe972..79f46d97 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,11 +49,11 @@ This is the standard guideline. Use this to help with sizing your icons and they ## Edit Readme -You will need to generate a new table for the README. To do this, run: +You will need to update the README. To do this, run: -`python3 generate_readme_table.py` +`python3 update_readme.py` -Copy the output and paste it over the old table. +This will update the average file size at the top of the file as well as regenerate the table of icons. ## Reference Image diff --git a/README.md b/README.md index 2da0b08e..087ebf66 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Super Tiny Icons -Under 1KB each! Super Tiny Web Icons are minuscule SVG versions of your favourite logos. The average size is _under_ 521 bytes! +Under 1KB each! Super Tiny Web Icons are minuscule SVG versions of your favourite logos. There are currently 363 icons and the average size is _under_ 519 bytes! The logos have a 512x512 viewbox, they will fit in a circle with radius 256. They will scale up and down to suit your needs. diff --git a/generate_readme_table.py b/generate_readme_table.py deleted file mode 100644 index bff7c782..00000000 --- a/generate_readme_table.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -import xml.etree.ElementTree as ET - -table_length = 6 -counter = 0 - -svg_list = sorted(os.listdir('images/svg/')) - -print("") -for svg in svg_list: - name = ET.parse('images/svg/'+svg).getroot().attrib["aria-label"] - if counter == 0 : - print("") - print( "") - counter +=1 - if counter == 6 : - print("\n") - counter = 0 -if counter != 0 : - print("\n") -print("
" + name + "
" + - '
' + - str( os.stat('images/svg/'+svg).st_size ) +" bytes
") \ No newline at end of file diff --git a/update_readme.py b/update_readme.py new file mode 100644 index 00000000..12567db7 --- /dev/null +++ b/update_readme.py @@ -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 = "\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 += "\n" + + table += f"\n" + + counter +=1 + + if counter == 6 : + table += "\n\n" + counter = 0 + +if counter != 0 : + table += "\n\n" + +table += "
{name}
" + table += f"
" + table += f"{bytes} bytes
" + +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, 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.") \ No newline at end of file