Show More
@@ -11,28 +11,25 b' time, these title and files will anyway be rewritten into the actual release' | |||||
11 | notes. |
|
11 | notes. | |
12 | """ |
|
12 | """ | |
13 |
|
13 | |||
14 | import glob |
|
14 | from pathlib import Path | |
15 |
|
||||
16 |
|
15 | |||
17 | def main(): |
|
16 | def main(): | |
18 | folder = 'docs/source/whatsnew/pr/' |
|
17 | folder = Path('docs/source/whatsnew/pr/') | |
19 | assert folder.endswith('/') |
|
18 | files = list(folder.glob('*.rst')) | |
20 | files = glob.glob(folder+'*.rst') |
|
|||
21 | print(files) |
|
19 | print(files) | |
22 |
|
20 | |||
23 |
for file |
|
21 | for filepath in files: | |
24 | print('Adding pseudo-title to:', filename) |
|
22 | print('Adding pseudo-title to:', filepath.name) | |
25 | title = filename[:-4].split('/')[-1].replace('-', ' ').capitalize() |
|
23 | title = filepath.name[:-4].split('/')[-1].replace('-', ' ').capitalize() | |
26 |
|
24 | |||
27 | with open(filename) as f: |
|
25 | data = filepath.read_text() | |
28 | data = f.read() |
|
|||
29 | try: |
|
26 | try: | |
30 | if data and data.splitlines()[1].startswith('='): |
|
27 | if data and data.splitlines()[1].startswith('='): | |
31 | continue |
|
28 | continue | |
32 | except IndexError: |
|
29 | except IndexError: | |
33 | pass |
|
30 | pass | |
34 |
|
31 | |||
35 |
with open( |
|
32 | with filepath.open('w') as f: | |
36 | f.write(title+'\n') |
|
33 | f.write(title+'\n') | |
37 | f.write('='* len(title)+'\n\n') |
|
34 | f.write('='* len(title)+'\n\n') | |
38 | f.write(data) |
|
35 | f.write(data) | |
@@ -40,7 +37,3 b' def main():' | |||||
40 | if __name__ == '__main__': |
|
37 | if __name__ == '__main__': | |
41 | main() |
|
38 | main() | |
42 |
|
39 | |||
43 |
|
||||
44 |
|
||||
45 |
|
||||
46 |
|
General Comments 0
You need to be logged in to leave comments.
Login now