diff --git a/update_readme.py b/update_readme.py index ec7cd94b..374bb08d 100644 --- a/update_readme.py +++ b/update_readme.py @@ -10,16 +10,30 @@ ref_list = sorted(os.listdir('images/reference/')) svg_data = {} total_bytes = 0 +# Loop through all the SVGs for svg_file in svg_list: + # Ignore anything which isn't an .svg if not svg_file.endswith('.svg'): continue + # Replace Windows line endings (CRLF) with Unix (LF) + with open( 'images/svg/' + svg_file, 'rb' ) as open_file: + content = open_file.read() + content = content.replace( b'\r\n', b'\n') + # Remove trailing newline + content = content.strip() + with open( 'images/svg/' + svg_file, 'wb' ) as open_file: + open_file.write(content) + # Get the filename of the service. E.g. service.svg svg = svg_file.split('.')[0] svg_data[svg] = { 'svg_file' : svg_file } + # Get the name of the service from the ARIA label svg_data[svg]['name'] = ET.parse(f'images/svg/{svg_file}').getroot().attrib["aria-label"] + # Get the file size bytes = os.stat(f'images/svg/{svg_file}').st_size svg_data[svg]['bytes'] = bytes total_bytes += bytes +# Get all reference images for ref_file in ref_list: if ref_file.endswith('.url'): continue @@ -27,12 +41,14 @@ for ref_file in ref_list: if ref_name in svg_data: svg_data[ref_name]['ref_file'] = ref_file +# Get all the reference URls for ref_url in ref_list: if ref_url.endswith('.url'): ref_name = ref_url.split('.')[0] if ref_name in svg_data: svg_data[ref_name]['source'] = open("images/reference/" + ref_url, "r").readline() +# Set up the tables readme_table = "
Name | SVG Icon | Circle Icon | Reference | Source |
---|---|---|---|---|
{name} |