1- ''' Generate example page with overview of all icons.'''
1+ """ Generate example page with overview of all icons."""
22
33from lxml import etree
44
5+ # pylint:disable=unspecified-encoding
6+
7+
58def parse (filename ):
6- ''' Parse SVG file containing icons.'''
9+ """ Parse SVG file containing icons."""
710 symbols = set ()
811 data = etree .parse (filename )
912 svg = data .getroot ()
1013 for symbol in svg :
1114 symbols .add (symbol .attrib ['id' ])
1215 return sorted (symbols )
1316
17+
1418def generate (version ):
15- ''' Write the HTML template file.'''
19+ """ Write the HTML template file."""
1620 head = f'''{{% extends 'base.html' %}}
1721{{% from 'bootstrap{ version } /utils.html' import render_icon %}}
18- <!-- DO NOT EDIT! Use update-icons .py for updating this file. -->
22+ <!-- DO NOT EDIT! Use update_icons .py for updating this file. -->
1923
2024{{% block content %}}
2125<h2>Icons</h2>
22- <p>These are all the icons which are currently supported by Bootstrap-Flask.</p>
26+ <p>These are all the icons currently supported by Bootstrap-Flask.</p>
2327<ul class="row row-cols-3 row-cols-sm-4 row-cols-lg-6 row-cols-xl-8 list-unstyled list">
2428'''
25- names = parse (f'../flask_bootstrap/static/bootstrap{ version } /icons/bootstrap-icons.svg' )
26- with open (f'bootstrap{ version } /templates/icons.html' , 'w' ) as file : # pylint:disable=unspecified-encoding
29+ names = parse (f'../flask_bootstrap/static/bootstrap{ version } /icons'
30+ '/bootstrap-icons.svg' )
31+ with open (f'bootstrap{ version } /templates/icons.html' , 'w' ) as file :
2732 file .write (head )
2833 number = 0
2934 for name in sorted (names ):
30- item = f'''<li class="col mb-4">
35+ item = f'''<li class="col mb-4">
3136<a class="d-block text-dark text-body-emphasis text-decoration-none" href="https://icons.getbootstrap.com/icons/{ name } /">
3237<div class="px-3 py-4 mb-2 bg-light text-center rounded">
3338{{{{ render_icon('{ name } ', 32) }}}}
@@ -40,8 +45,9 @@ def generate(version):
4045 number += 1
4146 file .write ('</ul>\n ' )
4247 file .write (f'<p>This is a total of { number } icons.</p>\n ' )
43- file .write ('{% endblock %}\n \n ' )
44- print (f'For Bootstrap{ version } , a total of { number } icons are supported.' )
48+ file .write ('{% endblock %}\n ' )
49+ print (f'For Bootstrap{ version } { number } icons are supported.' )
50+
4551
4652for value in (4 , 5 ):
4753 generate (value )
0 commit comments