Ejemplo n.º 1
0
 def saveCurrent(self):
     if self.curEdit:
         oldpath=os.path.join(self.dir,self.curEdit+".template")
         try:
             f=open(oldpath,'w')
             f.write(self.codeEdit.toPlainText())
             f.close()
         except IOError:
             utils.errorMessage('Cannot write file: {}'.format(oldpath))
Ejemplo n.º 2
0
 def addClicked(self):
     if not self.dir:
         utils.errorMessage('Please set template directory first')
     else:
         (label,ok)=QtGui.QInputDialog.getText(self,"New Template","Template Name")
         if ok:
             self.templatesList.addItem(label)
             try:
                 f=open(os.path.join(self.dir,label+".template"),'w')
                 f.write("\n")
                 f.close()
             except IOError:
                 utils.errorMessage('Could not write template file at: {}'.format(self.dir))
Ejemplo n.º 3
0
 def selChanged(self):
     self.saveCurrent()
     sel = self.templatesList.selectedItems()
     if len(sel) == 1:
         item = sel[0]
         label = item.text()
         path = os.path.join(self.dir, label + ".template")
         try:
             f = open(path, 'r')
             code = f.read()
             self.codeEdit.setPlainText(code)
             self.curEdit = label
         except IOError:
             utils.errorMessage('Cannot read file: {}'.format(path))
Ejemplo n.º 4
0
 def selChanged(self):
     self.saveCurrent()
     sel=self.templatesList.selectedItems()
     if len(sel)==1:
         item=sel[0]
         label=item.text()
         path=os.path.join(self.dir,label+".template")
         try:
             f=open(path,'r')
             code=f.read()
             self.codeEdit.setPlainText(code)
             self.curEdit=label
         except IOError:
             utils.errorMessage('Cannot read file: {}'.format(path))
Ejemplo n.º 5
0
 def addClicked(self):
     if not self.dir:
         utils.errorMessage('Please set template directory first')
     else:
         (label, ok) = QtGui.QInputDialog.getText(self, "New Template",
                                                  "Template Name")
         if ok:
             self.templatesList.addItem(label)
             try:
                 f = open(os.path.join(self.dir, label + ".template"), 'w')
                 f.write("\n")
                 f.close()
             except IOError:
                 utils.errorMessage(
                     'Could not write template file at: {}'.format(
                         self.dir))
Ejemplo n.º 6
0
 def __init__(self, msg, returnCode):
     # Error message is stored formatted in msg and response code stored in returnCode
     if isinstance(msg, str):
         self.msg = errorMessage(msg)
     else:
         self.msg = msg
     self.returnCode = returnCode