import sys if len(sys.argv) <= 1: exit(0) # Amb RGB # Dir RGB # Sky top RGB # Sky bot RGB # SunCore RGB # SunCorona RGB # SunSz float # SprSz float # SprBght float # Shdw int # LightShd int # TreeShd int # FarClp float # FogSt float # LightOnGround float # LowCloudsRGB RGB # TopCloudRGB RGB # BottomCloudRGB RGB # BlurRGBA RGBA fieldnames = ["Amb", "Dir", "Sky top", "Sky bot", "SunCore", "SunCorona", "SunSz", "SprSz", "SprBght", "Shdw", "LightShd", "TreeShd", "FarClp", "FogSt", "LightOnGround", "LowCloudsRGB", "TopCloudRGB", "BottomCloudRGB", "BlurRGBA"] weathernames = ["SUNNY", "CLOUDY", "RAINY", "FOGGY"] timenames = ["Midnight", "1AM", "2AM", "3AM", "4AM", "5AM", "6AM", "7AM", "8AM", "9AM", "10AM", "11AM", "Midday", "1PM", "2PM", "3PM", "4PM", "5PM", "6PM", "7PM", "8PM", "9PM", "10PM", "11PM"] def toNumbers(f): return {'Amb': [int(f[0]), int(f[1]), int(f[2])],\ 'Dir': [int(f[3]), int(f[4]), int(f[5])],\ 'SkyTop': [int(f[6]), int(f[7]), int(f[8])],\ 'SkyBot': [int(f[9]), int(f[10]), int(f[11])],\ 'SunCore': [int(f[12]), int(f[13]), int(f[14])],\ 'SunCorona': [int(f[15]), int(f[16]), int(f[17])],\ 'SunSz': float(f[18]),\ 'SprSz': float(f[19]),\ 'SprBght': float(f[20]),\ 'Shdw': int(f[21]),\ 'LightShd': int(f[22]),\ 'TreeShd': int(f[23]),\ 'FarClp': float(f[24]),\ 'FogSt': float(f[25]),\ 'LightOnGround': float(f[26]),\ 'LowClouds': [int(f[27]), int(f[28]), int(f[29])],\ 'TopClouds': [int(f[30]), int(f[31]), int(f[32])],\ 'BottomClouds': [int(f[33]), int(f[34]), int(f[35])],\ 'Blur': [int(f[36]), int(f[37]), int(f[38]), int(f[39])]} def liststr(l): return [str(x) for x in l] def toStrings(weather): return liststr(weather['Amb']) +\ liststr(weather['Dir']) +\ liststr(weather['SkyTop']) +\ liststr(weather['SkyBot']) +\ liststr(weather['SunCore']) +\ liststr(weather['SunCorona']) +\ [str(weather['SunSz'])] +\ [str(weather['SprSz'])] +\ [str(weather['SprBght'])] +\ [str(weather['Shdw'])] +\ [str(weather['LightShd'])] +\ [str(weather['TreeShd'])] +\ [str(weather['FarClp'])] +\ [str(weather['FogSt'])] +\ [str(weather['LightOnGround'])] +\ liststr(weather['LowClouds']) +\ liststr(weather['TopClouds']) +\ liststr(weather['BottomClouds']) +\ liststr(weather['Blur']) def getFieldWidths(lines): widths = [] for i in range(len(lines[0])): width = 0 for l in lines: if len(l[i]) > width: width = len(l[i]) widths.append(width) return widths def alignLine(fields, widths): return " ".join([f.rjust(w) for f, w in zip(fields, widths)]) def alignLineR(fields, widths): return " ".join([f.ljust(w) for f, w in zip(fields, widths)]) def combineTuples(lines, widths): newlines = [] for line in lines: l = [f.rjust(w) for f, w in zip(line, widths)] l = [" ".join(l[0:3]), " ".join(l[3:6]), " ".join(l[6:9]), " ".join(l[9:12]),\ " ".join(l[12:15]), " ".join(l[15:18]), l[18], l[19], l[20],\ l[21], l[22], l[23], l[24], l[25], l[26],\ " ".join(l[27:30]), " ".join(l[30:33]), " ".join(l[33:36]), " ".join(l[36:40])] newlines.append(l) return newlines path = sys.argv[1]; f = open(path, 'r') lines = [toNumbers(l.strip('\n').split()) for l in f.readlines() if l[0:2] != '//'] f.close() ## print compact = True lines = [toStrings(l) for l in lines] widths = getFieldWidths(lines) lines = combineTuples(lines, widths) widths = getFieldWidths([fieldnames] + lines) i = 0 for l in lines: if i % 24 == 0: print("//") print("/////////////////////////////////////////// " + weathernames[i//24]) print("//") if i % 12 == 0: if not compact or i % 24 == 0: print("// " + alignLineR(fieldnames, widths)) # if not compact or i % 24 == 0 or i % 24 == 12: if not compact or i % 3 == 0: print("// "+timenames[i%24]) print(" " + alignLineR(l, widths)) i += 1