Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-30 09:40:28

0001 import os
0002 import sys
0003 import re
0004 
0005 # Sets up the config.json.
0006 # This allows the website script to know the available SVGs.
0007 
0008 svg_relative_path = "svgs"
0009 current_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
0010 svg_directory = os.path.join(current_directory, svg_relative_path)
0011 
0012 if os.path.exists(svg_directory) and os.path.isdir(svg_directory):
0013     # Get the file names.
0014     file_names = os.listdir(svg_directory)
0015     print("Found SVG directory with " + str(len(file_names)) + " files")
0016 
0017     # Sort the file names alphanumerically.
0018     convert = lambda text: int(text) if text.isdigit() else text.lower()
0019     alphanum_key = lambda key: [convert(c) for c in re.split("([0-9]+)", key)]
0020     file_names.sort(key=alphanum_key)
0021 
0022     # Write the json file used by the webpage.
0023     outputFile = os.path.join(current_directory, "config.json")
0024     with open(outputFile, "w") as file:
0025         content = "[" + ", ".join(['"' + f + '"' for f in file_names]) + "]"
0026         file.write(content)
0027     print("Build Complete")
0028 else:
0029     print("Build Error: Directory Not Found")