def __init__(self, oldprojectname, newprojectname): cwapi_new = CWCoreAPI() cwapi_old = CWCoreAPI() cwapi_old.openProject(oldprojectname) cwapi_new.newProject() cwapi_new.saveProject(newprojectname) tm = cwapi_old.project().traceManager() ntraces = tm.numTraces() segs = tm.getSegmentList() numtraces = 0 for offset, seg_idx in enumerate(segs['offsetList']): seg_len = segs['lengthList'][seg_idx] seg = tm.getSegment(seg_idx) tc = TraceContainerNative() tc.clear() # Copy all aux data over # seg.config._configfile tc.config.config = seg.config.config prefix = tc.config.config['Trace Config']['prefix'] tc.config.setConfigFilename(cwapi_new.project().datadirectory + "traces/config_" + prefix + ".cfg") tc.setDirty(True) tc.config.syncFile() for tnum in range(offset, seg_len + offset): trace = tm.getTrace(tnum) textin = tm.getTextin(tnum) textout = tm.getTextout(tnum) key = tm.getKnownKey(tnum) try: textin, textout, trace, key = self.trace_callback( textin, textout, trace, key) except StopIteration: continue numtraces += 1 tc.addTrace(trace, textin, textout, key) tc.closeAll() cwapi_new.project().traceManager().appendSegment(tc) cwapi_new.saveProject()