Skip to content

Commit 91ccfb7

Browse files
hugovkmerwok
andauthored
Use underscores instead of spaces in paths (#332)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
1 parent 9bfd703 commit 91ccfb7

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

blurb_it/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
async def get_misc_news_filename(issue_number, section, body):
12+
if " " in section:
13+
raise ValueError(f"Use underscores not spaces in section name: {section}")
1214
date = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
1315
nonce = await nonceify(body)
1416
path = f"Misc/NEWS.d/next/{section}/{date}.gh-issue-{issue_number}.{nonce}.rst"

templates/add_blurb.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ <h3>📜🤖 Blurb it again?</h3>
3838
<select id="section" name="section" class="form-control form-inline" required>
3939
<option></option>
4040
<option>Security</option>
41-
<option>Core and Builtins</option>
41+
<option value="Core_and_Builtins">Core and Builtins</option>
4242
<option>Library</option>
4343
<option>Documentation</option>
4444
<option>Tests</option>
4545
<option>Build</option>
4646
<option>Windows</option>
4747
<option>macOS</option>
4848
<option>IDLE</option>
49-
<option>Tools-Demos</option>
50-
<option>C API</option>
49+
<option value="Tools-Demos">Tools and Demos</option>
50+
<option value="C_API">C API</option>
5151
</select>
5252
</div>
5353
</div>

tests/test_util.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ async def test_get_misc_news_filename():
5757
assert path.endswith(".gh-issue-123.Ps4kgC.rst")
5858

5959

60+
async def test_get_misc_news_filename_sections_with_dashes():
61+
path = await util.get_misc_news_filename(
62+
issue_number=123,
63+
section="Core_and_Builtins",
64+
body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim",
65+
)
66+
67+
assert path.startswith("Misc/NEWS.d/next/Core_and_Builtins/")
68+
69+
70+
async def test_get_misc_news_filename_sections_with_space():
71+
with pytest.raises(
72+
ValueError,
73+
match="Use underscores not spaces in section name: Core and Builtins",
74+
):
75+
await util.get_misc_news_filename(
76+
issue_number=123,
77+
section="Core and Builtins",
78+
body="Lorem ipsum dolor amet flannel squid normcore tbh raclette enim",
79+
)
80+
81+
6082
async def test_has_session():
6183
request = mock_request_session()
6284

0 commit comments

Comments
 (0)