forked from edent/SuperTinyIcons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to update README in place (edent#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
- Loading branch information
Showing
4 changed files
with
51 additions
and
27 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |