def openF(self): path = QtGui.QFileDialog.getOpenFileName(self,'Open File','','CSV(*.csv)') if not path.isEmpty(): with open(unicode(path),'rb') as stream: self.tableWidget.setRowCount(0) self.tableWidget.setColumnCount(0) for rowdata in csv.reader(stream): row = self.tableWidget.rowCount() self.tableWidget.insertRow(row) self.tableWidget.setColumnCount(len(rowdata)) for column, data in enumerate(rowdata): item = QtGui.QTableWidgetItem(data.decode('utf8')) self.tableWidget.setItem(row,column,item)
def save(self): self.runSource.intendedFinish = '(C)Distillate' path = QtGui.QFileDialog.getSaveFileName(self,'Save File','','CSV(*.csv)') if not path.isEmpty(): with open(unicode(path),'wb') as stream: writer = csv.writer(stream) for row in range(self.tableWidget.rowCount()): rowdata = [] for column in range(self.tableWidget.columnCount()): item = self.tableWidget.item(row,column) if item is not None: rowdata.append(unicode(item.text()).encode('utf8')) else: rowdata.append('') writer.writerow(rowdata) writer.writerow([self.runSource,'','','','','','','','','']) cl.save()
def addDeepPlug(self, topNet, path): if path.isEmpty(): return None tailPath = path.getTailPath() headInstance = path.getHeadInstance() headPlug = getPlugByNet(headInstance, topNet) if headPlug: if tailPath.isEmpty(): return headPlug return self.addDeepPlug(headPlug.getMasterNet(), tailPath) masterCell = headInstance.getMasterCell() masterNet = Net.create(masterCell, topNet.getName()) masterNet.setExternal(True) masterNet.setType(Net.Type.CLOCK) masterNet.setDirection(Net.Direction.IN) headPlug = headInstance.getPlug(masterNet) if not headPlug: raise ErrorMessage( 3, 'Plug not created for %s on instance %s of %s' \ % (topNet.getName(),headInstance.getName(),masterCell.getName()) ) headPlug.setNet(topNet) self.addCloned(masterCell) if tailPath.isEmpty(): return headPlug return self.addDeepPlug(masterNet, tailPath)