Created
January 19, 2015 21:34
-
-
Save gartenfeld/4abbf505df43461031c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import os | |
import locale | |
def inspect_file(file_name): | |
# Do stuff | |
return | |
def process_all(files_list): | |
for i, file_name in enumerate(files_list): | |
inspect_file(file_name) | |
return | |
def load_directory(source_path): | |
files_list = [] | |
for file_name in os.listdir(source_path): | |
try: | |
if file_name.endswith(".html"): | |
files_list.append(file_name) | |
except IndexError: | |
sys.stderr.write("Something went wrong with " + file_name + ".") | |
continue | |
locale.setlocale(locale.LC_ALL, 'en_AU') | |
number_of_files = locale.format("%d", len(files_list), grouping=True) | |
print(number_of_files + " files loaded.") | |
return files_list | |
def clear_output_file(file): | |
output_file = open(file, 'w') | |
output_file.write("") | |
output_file.close() | |
return | |
if __name__ == '__main__': | |
source_path = "DIR/" | |
output_file = "out.html" | |
file_header = "<html>\n<head>\n<meta charset='utf-8'>\n</head>\n<body>\n" | |
file_footer = "\n</body>\n</html>" | |
print("Loading files...") | |
files_list = load_directory(source_path) | |
clear_output_file(output_file) | |
print("Processing all files...") | |
process_all(files_list) | |
print("Valmis!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment