@@ -95,8 +95,13 @@ class BlurbError(RuntimeError):
95
95
96
96
97
97
class Blurbs (list ):
98
- def parse (self , text : str , * , metadata : dict [str , str ] | None = None ,
99
- filename : str = 'input' ) -> None :
98
+ def parse (
99
+ self ,
100
+ text : str ,
101
+ * ,
102
+ metadata : dict [str , str ] | None = None ,
103
+ filename : str = 'input' ,
104
+ ) -> None :
100
105
"""Parses a string.
101
106
102
107
Appends a list of blurb ENTRIES to self, as tuples: (metadata, body)
@@ -147,13 +152,17 @@ def finish_entry() -> None:
147
152
throw (f'Invalid { issue_keys [key ]} number: { value !r} ' )
148
153
149
154
if key == 'gh-issue' and int (value ) < lowest_possible_gh_issue_number :
150
- throw (f'Invalid gh-issue number: { value !r} (must be >= { lowest_possible_gh_issue_number } )' )
155
+ throw (
156
+ f'Invalid gh-issue number: { value !r} (must be >= { lowest_possible_gh_issue_number } )'
157
+ )
151
158
152
159
if key == 'section' :
153
160
if no_changes :
154
161
continue
155
162
if value not in sections :
156
- throw (f'Invalid section { value !r} ! You must use one of the predefined sections.' )
163
+ throw (
164
+ f'Invalid section { value !r} ! You must use one of the predefined sections.'
165
+ )
157
166
158
167
if 'gh-issue' not in metadata and 'bpo' not in metadata :
159
168
throw ("'gh-issue:' or 'bpo:' must be specified in the metadata!" )
@@ -232,7 +241,9 @@ def _parse_next_filename(filename: str) -> dict[str, str]:
232
241
assert section in sections , f'Unknown section { section } '
233
242
234
243
fields = [x .strip () for x in filename .split ('.' )]
235
- assert len (fields ) >= 4 , f"Can't parse 'next' filename! filename { filename !r} fields { fields } "
244
+ assert len (fields ) >= 4 , (
245
+ f"Can't parse 'next' filename! filename { filename !r} fields { fields } "
246
+ )
236
247
assert fields [- 1 ] == 'rst'
237
248
238
249
metadata = {'date' : fields [0 ], 'nonce' : fields [- 2 ], 'section' : section }
@@ -263,7 +274,7 @@ def ensure_metadata(self) -> None:
263
274
('bpo' , '0' ),
264
275
('date' , sortable_datetime ()),
265
276
('nonce' , generate_nonce (body )),
266
- ):
277
+ ):
267
278
if name not in metadata :
268
279
metadata [name ] = default
269
280
@@ -274,10 +285,14 @@ def _extract_next_filename(self) -> str:
274
285
metadata ['section' ] = sanitize_section (metadata ['section' ])
275
286
metadata ['root' ] = root
276
287
if int (metadata ['gh-issue' ]) > 0 :
277
- path = '{root}/Misc/NEWS.d/next/{section}/{date}.gh-issue-{gh-issue}.{nonce}.rst' .format_map (metadata )
288
+ path = '{root}/Misc/NEWS.d/next/{section}/{date}.gh-issue-{gh-issue}.{nonce}.rst' .format_map (
289
+ metadata
290
+ )
278
291
elif int (metadata ['bpo' ]) > 0 :
279
292
# assume it's a GH issue number
280
- path = '{root}/Misc/NEWS.d/next/{section}/{date}.bpo-{bpo}.{nonce}.rst' .format_map (metadata )
293
+ path = '{root}/Misc/NEWS.d/next/{section}/{date}.bpo-{bpo}.{nonce}.rst' .format_map (
294
+ metadata
295
+ )
281
296
for name in ('root' , 'section' , 'date' , 'gh-issue' , 'bpo' , 'nonce' ):
282
297
del metadata [name ]
283
298
return path
@@ -294,4 +309,4 @@ def save_next(self) -> str:
294
309
295
310
296
311
def sortable_datetime () -> str :
297
- return time .strftime (" %Y-%m-%d-%H-%M-%S" , time .localtime ())
312
+ return time .strftime (' %Y-%m-%d-%H-%M-%S' , time .localtime ())
0 commit comments