Skip to content

Commit 2c1f431

Browse files
PanderMusubigreyli
andauthored
refactored dev scripts (#386)
Co-authored-by: Grey Li <[email protected]>
1 parent 53721c0 commit 2c1f431

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

examples/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ with:
4242

4343
.. code-block:: bash
4444
45-
$ python3 update-icons.py
45+
$ python3 update_icons.py
4646

examples/bootstrap4/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class ContactForm(FlaskForm):
9797

9898
class BootswatchForm(FlaskForm):
9999
"""Form to test Bootswatch."""
100-
101-
# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
100+
# DO NOT EDIT! Use list_bootswatch.py to generate the Radiofield below.
102101
theme_name = RadioField(
103102
default='default',
104103
choices=[

examples/bootstrap4/templates/icons.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{% extends 'base.html' %}
22
{% from 'bootstrap4/utils.html' import render_icon %}
3-
<!-- DO NOT EDIT! Use update-icons.py for updating this file. -->
3+
<!-- DO NOT EDIT! Use update_icons.py for updating this file. -->
44

55
{% block content %}
66
<h2>Icons</h2>
7-
<p>These are all the icons which are currently supported by Bootstrap-Flask.</p>
7+
<p>These are all the icons currently supported by Bootstrap-Flask.</p>
88
<ul class="row row-cols-3 row-cols-sm-4 row-cols-lg-6 row-cols-xl-8 list-unstyled list">
99
<li class="col mb-4">
1010
<a class="d-block text-dark text-body-emphasis text-decoration-none" href="https://icons.getbootstrap.com/icons/0-circle/">
@@ -16409,4 +16409,3 @@ <h2>Icons</h2>
1640916409
</ul>
1641016410
<p>This is a total of 2050 icons.</p>
1641116411
{% endblock %}
16412-

examples/bootstrap5/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ContactForm(FlaskForm):
9898
class BootswatchForm(FlaskForm):
9999
"""Form to test Bootswatch."""
100100

101-
# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
101+
# DO NOT EDIT! Use list_bootswatch.py to generate the Radiofield below.
102102
theme_name = RadioField(
103103
default='default',
104104
choices=[

examples/bootstrap5/templates/icons.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{% extends 'base.html' %}
22
{% from 'bootstrap5/utils.html' import render_icon %}
3-
<!-- DO NOT EDIT! Use update-icons.py for updating this file. -->
3+
<!-- DO NOT EDIT! Use update_icons.py for updating this file. -->
44

55
{% block content %}
66
<h2>Icons</h2>
7-
<p>These are all the icons which are currently supported by Bootstrap-Flask.</p>
7+
<p>These are all the icons currently supported by Bootstrap-Flask.</p>
88
<ul class="row row-cols-3 row-cols-sm-4 row-cols-lg-6 row-cols-xl-8 list-unstyled list">
99
<li class="col mb-4">
1010
<a class="d-block text-dark text-body-emphasis text-decoration-none" href="https://icons.getbootstrap.com/icons/0-circle/">
@@ -16409,4 +16409,3 @@ <h2>Icons</h2>
1640916409
</ul>
1641016410
<p>This is a total of 2050 icons.</p>
1641116411
{% endblock %}
16412-
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from os import listdir
44

5+
# pylint:disable=unspecified-encoding
56

6-
def list(version):
7+
8+
def list_names(version):
79
"""List template file names."""
810
print(f"To add to bootstrap{version}/app.py")
911
print(" theme_name = RadioField(")
@@ -23,4 +25,4 @@ def list(version):
2325

2426

2527
for value in (4, 5):
26-
list(value)
28+
list_names(value)
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
'''Generate example page with overview of all icons.'''
1+
"""Generate example page with overview of all icons."""
22

33
from lxml import etree
44

5+
# pylint:disable=unspecified-encoding
6+
7+
58
def 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+
1418
def 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

4652
for value in (4, 5):
4753
generate(value)

0 commit comments

Comments
 (0)