Updated list_langs (now in python) and executed it
This commit is contained in:
25
list_langs.py
Executable file
25
list_langs.py
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
|
||||
readme = open('README.md', 'w')
|
||||
|
||||
# Copy template to README
|
||||
with open('README_nolist.md', 'r') as temp:
|
||||
for line in temp:
|
||||
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 dir in os.listdir('.'):
|
||||
if not (dir == '.' or dir == '..' or dir[0] == '.' or os.path.isfile(dir)):
|
||||
for file in os.listdir(dir):
|
||||
if os.path.isfile(f"{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('* ' + lang[:-1] + '\n') # Cut trailing space
|
||||
|
||||
readme.close()
|
||||
@@ -1,13 +0,0 @@
|
||||
Dir.foreach "." do |odir|
|
||||
next if odir == "." or odir == ".." or not File.directory?(odir)
|
||||
Dir.foreach odir do |dir|
|
||||
next if dir == "." or dir == ".."
|
||||
currdirname = ""
|
||||
dir.split(".")[0].gsub("-", " ").gsub("_", " ").split(" ").each do |str|
|
||||
currdirname << str.capitalize + " "
|
||||
end
|
||||
currdirname.chomp(currdirname[-1])
|
||||
puts "* #{currdirname}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user