From c27674d6507edf7bc876b26d7bab20006cfd1536 Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Mon, 6 Apr 2020 01:02:09 -0700 Subject: [PATCH] Adds a very basic script to update all contributors section on the website --- .../update-all-contributors-website.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 bin/scripts/update-all-contributors-website.py diff --git a/bin/scripts/update-all-contributors-website.py b/bin/scripts/update-all-contributors-website.py new file mode 100755 index 0000000000..1fc97e1eb6 --- /dev/null +++ b/bin/scripts/update-all-contributors-website.py @@ -0,0 +1,54 @@ +import fileinput +import string +import re + +file = open("../../CONTRIBUTORS.md", "r") +contributorContents = file.read() +file.close() + +# print(contributorContents) + + +file = open("/home/ryan/projects/nerd-fonts-gh-pages/_posts/2017-01-05-all-contributors.md", "r") +webContributorContents = file.read() +file.close() + +# print(webContributorContents) + +# search and replace +starting_text = '' +ending_text = '' +to_replace = webContributorContents[webContributorContents.find(starting_text)+len(starting_text):webContributorContents.rfind(ending_text)] + +print('re replace') +print('-------------------------------------------------') +print(to_replace) + +# Remove markdown that won't work as-is in the jekyll page: +transformedContributorContents = re.sub('[![All Contributors](.*)\(#contributors\)\n', '', contributorContents) +transformedContributorContents = re.sub('Thanks goes to these wonderful people(.*):\n', '', transformedContributorContents) +transformedContributorContents = string.replace(transformedContributorContents, '## Contributors\n\n', '') +transformedContributorContents = string.replace(transformedContributorContents, 'This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!', '') + +# Fix the formatting for the grid table: +transformedContributorContents = string.replace(transformedContributorContents, ' [\n[') +transformedContributorContents = string.replace(transformedContributorContents, '| :---: | :---: | :---: | :---: | :---: | :---: | :---: |', '') +transformedContributorContents = string.replace(transformedContributorContents, '', '') +transformedContributorContents = string.replace(transformedContributorContents, '|\n', '') # @TODO fixme + + +print('transformed contr contents') +print('-------------------------------------------------') +print(transformedContributorContents) + +webContributorContents = string.replace(webContributorContents, to_replace, transformedContributorContents) + +print('final out') +print('-------------------------------------------------') +print(webContributorContents) + + +# write the updated all contributors to the website +file = open("/home/ryan/projects/nerd-fonts-gh-pages/_posts/2017-01-05-all-contributors.md", "w") +file.write(webContributorContents)