# buildReport # a poorly named script for formatting a folder of code to show on pmWiki # # Tim Hirzel # Feb 2008 # # released under Creative Commons Attribution-Noncommercial-Share Alike 3.0 import os, time, sys from string import Template VERSION = float(sys.argv[1]) CODESTART = "\n(:source lang=c:)\n" CODEEND = "\n(:sourcend:)\n" # in this text area, us a '$' behind the file name (with '.pde' extension) and it will insert the contents of that file. #a nice update would be to allow an automatic intro text, and auto table of contents. But automatic is sometimes worse than plain and stupid anyways. text=""" !! Code The current version is %.2f\\\\ last updated: %s\\\\ jump to code section:\\\\ [[#main | Main]]\\\\ [[#pid | PID]]\\\\ [[#heater | Heater]]\\\\ [[#eeprom | EEPROM Floats]]\\\\ [[#temp | Temp Sensing]]\\\\ [[#serial | Serial Interface]]\\\\ [[#main]] !! Main $BBCC_Core [[#pid]] !! PID control algorithm $PID [[#heater]] !! Heater Control (PWM) $HeaterControl [[#eeprom]] !! EEPROM float storage utility $EEPROMFloat [[#temp]] !! Temperature Sensor $TempSensor [[#serial]] !! Serial Interface $SerialInterface """ % (VERSION, time.strftime("%H:%M %b %d %Y")) t = Template(text) local = os.listdir('.') local.sort() files = {} for f in local: if f.endswith(".pde"): content = open(f,'r').read() files[f[:-4]] =CODESTART + content + CODEEND t = t.substitute(files) outfile = open("report-v%.2f.txt"%VERSION, 'w') outfile.write(t) outfile.close()