""" Minetest Mod HTML Generator Program """ #Imports import json #Grabs dictionary of mod from master dictionary def grabMod(modName): mod = master_dict[modName] return mod #Extracts each part from mod dictionary def extractMod(mod): name = mod["Name"] folder = mod["Folder"] author = mod["Author"] depends = mod["Depends"] forum = mod["Forum"] database = mod["Database"] gitHub = mod["GitHub"] categories = mod["Categories"] #Wrtie HTML code from mod list def writeHTML(): html_code = [""] #Prints general beginning HTML #Note that "style.css" can be used to style the generated page html_code.append("") html_code.append("List of Mods
") #Outputs Table of Contents html_code.append("
") html_code.append("

Table of Contents

") html_code.append("") html_code.append("
") #Ouputs list header html_code.append("

List of Mods

") #Prints info for each mod in alphabetical order for modName, mod in sorted(master_dict.items()): html_code.append("

" + mod["Name"] + " [" + mod["Folder"] + "]

") html_code.append("") html_code.append("
") #Prints general ending HTML code html_code.append("
") #Create HTML file html_file = open("mod_list.html", "w") #Write to HTML file html_file.write(str.join("\n", html_code)) #Print HTML print(str.join("\n", html_code)) #Close HTML file html_file.close() #Open data file and get master directory from data file data_file = "mod_data.txt" global master_dict master_dict = {} master_dict = json.load(open(data_file)) #Call writeHTML function writeHTML()