From d970061863ebc91c05c1e7efaa56c63c224f3555 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Wed, 1 Jul 2020 17:02:15 +1200 Subject: [PATCH] Modify language list in place and add count Signed-off-by: Richie Bendall --- CONTRIBUTING.md | 6 +++--- README.md | 22 ++++++++++++---------- README_nolist.md | 14 -------------- list_langs.py | 25 ------------------------- update_list.py | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 52 deletions(-) delete mode 100755 README_nolist.md delete mode 100755 list_langs.py create mode 100644 update_list.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55eb5a72c..5e6140bde 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,12 +4,12 @@ #### Naming -The file should be name according to the language it was written. The name shouldn't be abbreviated too far (`Javascript.js` instead of `JS.js`) and it shouldn't be abbreviated to little (`CSS.css` instead of `Cascading Style Sheets.css`). Additionally, hyphens should be used instead of spaces (`Objective-C.m` instead of `Objective C.m`). +The file should be named according to the language it was written. The name shouldn't be abbreviated too far (`Javascript.js` instead of `JS.js`) and it shouldn't be abbreviated to little (`CSS.css` instead of `Cascading Style Sheets.css`). Additionally, hyphens should be used instead of spaces (`Objective-C.m` instead of `Objective C.m`). #### Contents -The code in the file should be the simplest or most straightforward way to print/display/show `Hello World` exactly once in the language used. Input from the user shouldn't be asked for where possible and a newline should only be printed when nessesary. +The code in the file should be the simplest or most straightforward way to print/display/show `Hello World` exactly once in the language used. Input from the user shouldn't be asked for where possible and a newline should only be printed when necessary. ### Updating README -All changes to the README should be done in `README_nolist.md` instead and `list_langs.py` (Python 3.6+) should be run to automatically update the main one. +`update_list.py` (Python 3.6+) should be run to automatically update the language list. diff --git a/README.md b/README.md index 0ed3de32e..ce5f86b94 100755 --- a/README.md +++ b/README.md @@ -1,19 +1,15 @@ -Hello World! -============= +# Hello World -> Inspired by [The Hello World Collection](https://helloworldcollection.github.io/). - -#### Hello world in every computer language. +Hello world in every computer language. As I watch the collection expand, this project has blown up more than I ever thought possible. -Thanks to everyone who continues to contribute, new languages are created every day! +Thanks to everyone who continues to contribute; new languages are created every day! Make sure to see [CONTRIBUTING.md](/CONTRIBUTING.md) for instructions on contributing to the project! -Spin-Off project smartly suggested and implemented by [@zenware](https://github.com/zenware): -Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-world](https://github.com/leachim6/hello-world). + +## Languages (661 total) -### This repository currently contains "Hello World" programs in the following languages: * [05Ab1E](%23/05AB1E) * [0815](%23/0815.0815) * [1C Enterprise](%23/1c-enterprise) @@ -484,7 +480,7 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo * [Profan](p/profan) * [Prolog](p/prolog.pro) * [Promela](p/promela.pml) -* [ProvideX](p/providex.vim) +* [Providex](p/providex.vim) * [Pug](p/pug.pug) * [Pure Data](p/pure_data.pd) * [Purebasic](p/purebasic.pb) @@ -675,3 +671,9 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo * [Zombie](z/zombie.zombie) * [Zonnon](z/zonnon.znn) * [Zsh](z/zsh.zsh) + + +## Related + +- [FizBuzz](https://github.com/zenware/FizzBuzz) +- [The Hello World Collection](https://helloworldcollection.github.io/). diff --git a/README_nolist.md b/README_nolist.md deleted file mode 100755 index 777eaf233..000000000 --- a/README_nolist.md +++ /dev/null @@ -1,14 +0,0 @@ -Hello World! -============= - -> Inspired by [The Hello World Collection](https://helloworldcollection.github.io/). - -#### Hello world in every computer language. - -As I watch the collection expand, this project has blown up more than I ever thought possible. -Thanks to everyone who continues to contribute, new languages are created every day! - -Make sure to see [CONTRIBUTING.md](/CONTRIBUTING.md) for instructions on contributing to the project! - -Spin-Off project smartly suggested and implemented by [@zenware](https://github.com/zenware): -Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-world](https://github.com/leachim6/hello-world). diff --git a/list_langs.py b/list_langs.py deleted file mode 100755 index 8cd3456b6..000000000 --- a/list_langs.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 - -import os -import posixpath -from urllib.parse import quote - -readme = open('README.md', 'w', encoding="utf-8") - -# Copy template to README -with open('README_nolist.md', 'r') as file: - for line in file: - readme.write(line) - -# Write title -readme.write('\n### This repository currently contains "Hello World" programs in the following languages:\n') - -# List the available languages -for directory in sorted(os.listdir('.')): - if not (directory == '.' or directory == '..' or directory[0] == '.' or os.path.isfile(directory)): - for filename in sorted(os.listdir(directory), key=lambda s: s.lower()): - if os.path.isfile(os.path.join(directory, filename)): - language = os.path.splitext(filename)[0].replace('-', ' ').replace('_', ' ').title() - readme.write(f'* [{language}]({posixpath.join(quote(directory), quote(filename))})\n') - -readme.close() diff --git a/update_list.py b/update_list.py new file mode 100644 index 000000000..996e87c54 --- /dev/null +++ b/update_list.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import os +import posixpath +from urllib.parse import quote +import re + + +def regexReplace(string, search, replacement): + return re.compile(search).sub(replacement, string) + + +languageCount = 0 +languagesText = "" + +# List the available languages +for directory in sorted(os.listdir('.')): + if not (directory == '.' or directory == '..' or directory[0] == '.' or os.path.isfile(directory)): + for filename in sorted(os.listdir(directory), key=lambda s: s.lower()): + if os.path.isfile(os.path.join(directory, filename)): + language = os.path.splitext(filename)[0].replace( + '-', ' ').replace('_', ' ').title() + languagesText += f'* [{language}]({posixpath.join(quote(directory), quote(filename))})\n' + languageCount += 1 + +result = f""" +## Languages ({languageCount} total) + +{languagesText}""" + +readmeContents = open('README.md', 'r', encoding="utf-8").read() + +open('README.md', 'w', encoding="utf-8").write(regexReplace( + readmeContents, r"(.|\n)*", result))