def writeTestSteps(aIni, aPath): cfg = ConfigParser.ConfigParser() cfg.readfp(file(aIni)) for s in cfg.sections(): typ = cfg.get(s, 'Type').lower() if typ == 'command': folded = getFolded(getEntries(cfg.get(s, 'Datafile')), getTypes(cfg.get(s, 'Typefile')), 3) writeCommandTestSteps( folded, string.Template( file(cfg.get(s, 'TestStepHeaderTemplate')).read()), string.Template( file(cfg.get(s, 'TestStepSourceTemplate')).read()), aPath) elif typ == 'event': writeEventTestSteps( getFolded(getEntries(cfg.get(s, 'Datafile')), getTypes(cfg.get(s, 'Typefile')), 0), string.Template( file(cfg.get(s, 'TestStepHeaderTemplate')).read()), string.Template( file(cfg.get(s, 'TestStepSourceTemplate')).read()), aPath) elif typ == 'completeevent': writeCompleteEventTestSteps( getFolded(getEntries(cfg.get(s, 'Datafile')), getTypes(cfg.get(s, 'Typefile')), 0), string.Template( file(cfg.get(s, 'TestStepHeaderTemplate')).read()), string.Template( file(cfg.get(s, 'TestStepSourceTemplate')).read()), aPath)
def makeTestSteps(aCfg, aSections): if aSections == []: return [] else: return makeTestStep(aCfg.get(aSections[0], 'Type'), getFolded(getEntries(aCfg.get(aSections[0], 'Datafile')), getTypes(aCfg.get(aSections[0], 'Typefile')), 0)) + makeTestSteps(aCfg, aSections[1:])
return scanned, args opts, args = getOpts() if len(opts) < 2: printHelp() else: if opts['COMMAND'] == 'mmp': # Generate mmp file writeMMPFile(opts['INI'], string.Template(file(args[0]).read()), args[1]) elif opts['COMMAND'] == 'impl': # Generate implementation cfg = ConfigParser.ConfigParser() cfg.readfp(file(opts['INI'])) for s in cfg.sections(): entries = getEntries(cfg.get(s, 'Datafile')) types = getTypes(cfg.get(s, 'Typefile')) headerTemplate = string.Template(file(cfg.get(s, 'HeaderTemplate')).read()) sourceTemplate = string.Template(file(cfg.get(s, 'SourceTemplate')).read()) typ = cfg.get(s, 'Type').lower() if os.path.exists(cfg.get(s, 'SourcePath')) == False: os.mkdir(cfg.get(s, 'SourcePath')) if os.path.exists(cfg.get(s, 'HeaderPath')) == False: os.mkdir(cfg.get(s, 'HeaderPath')) if typ == 'command': folded = getFolded(entries, types, 3) print('Writing %i commands\n\theaders at %s\n\tsource at %s...' % (len(folded), cfg.get(s, 'HeaderPath'), cfg.get(s, 'SourcePath')))