Skip to content

Commit

Permalink
Merge pull request #12552 from rushabh-v/pathlib_fwpr
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Sep 14, 2020
2 parents fedd6a8 + 50a8bd8 commit d51e575
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions tools/fixup_whats_new_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,29 @@
notes.
"""

import glob

from pathlib import Path

def main():
folder = 'docs/source/whatsnew/pr/'
assert folder.endswith('/')
files = glob.glob(folder+'*.rst')
folder = Path("docs/source/whatsnew/pr/")
files = list(folder.glob("*.rst"))
print(files)

for filename in files:
print('Adding pseudo-title to:', filename)
title = filename[:-4].split('/')[-1].replace('-', ' ').capitalize()
for filepath in files:
print("Adding pseudo-title to:", filepath.name)
title = filepath.name[:-4].split("/")[-1].replace("-", " ").capitalize()

with open(filename) as f:
data = f.read()
data = filepath.read_text()
try:
if data and data.splitlines()[1].startswith('='):
continue
except IndexError:
pass

with open(filename, 'w') as f:
f.write(title+'\n')
f.write('='* len(title)+'\n\n')
with filepath.open("w") as f:
f.write(title + "\n")
f.write("=" * len(title) + "\n\n")
f.write(data)

if __name__ == '__main__':
main()





0 comments on commit d51e575

Please sign in to comment.