sorted listings. changed to use urllib for listing percent-encode

This commit is contained in:
Clement Ng
2017-04-04 01:42:13 +10:00
parent cf9f6b323e
commit 62307757e2
2 changed files with 486 additions and 486 deletions

View File

@@ -14,13 +14,13 @@ with open('README_nolist.md', 'r') as temp:
readme.write('\n### This repository currently contains "Hello World" programs in the following languages:\n')
# List the available languages
for dir in os.listdir('.'):
for dir in sorted(os.listdir('.')):
if not (dir == '.' or dir == '..' or dir[0] == '.' or os.path.isfile(dir)):
for file in os.listdir(dir):
for file in sorted(os.listdir(dir), key=lambda s: s.lower()):
if os.path.isfile(os.path.join(dir, file)):
lang = ''
for str in file[0:(len(file) if file.find('.') == -1 else file.find('.'))].replace('-', ' ').replace('_', ' ').split():
lang += str.capitalize() + ' '
readme.write('* [{}]({})\n'.format(lang[:-1], quote(os.path.join(dir if dir != "#" else "%23", file)))) # Cut trailing space
readme.write('* [{}]({})\n'.format(lang[:-1], quote(os.path.join(dir, file)))) # Cut trailing space
readme.close()