def saveTree(self): tmpFile = "sharedSourceBackup_" + dateStamp() S = SharedSourceTree2XMLFile(tmpFile, self.treeModel.rootItem) fileName = QtGui.QFileDialog.getSaveFileName(self, "Path_to_", Path.config("treeBackup")) if not moveFile(Path.multiPath(Path.tempStruct, "server", tmpFile), QtCore.QString(fileName).toUtf8().data()): showHelp = ListingText("MSG: tree not saved.", self) showHelp.exec_()
def filePrepare(self): self.doc.appendChild(self.treeSharedDataToXML(self.rootItem)) #print self.doc.toprettyxml() try : fileName = Path.multiPath(Path.tempStruct, 'server', self.fileName) with open(fileName, 'wb') as f : #f.write(doc.toprettyxml()) ## без доп параметров неправильно отображает дерево self.doc.writexml(f, encoding = 'utf-8') #with open(fileName, 'rb') as f : # print 'Create item File %s :\n%s\n---END---\n' % (fileName, f.read()) except UnicodeError , err: print '[SharedSourceTree2XMLFile.filePrepare() : File not saved]', err
def setMaskSet(self): path_ = Path.multiPath(Path.tempStruct, 'client', self.nameMaskFile) if not os.path.isfile(path_) : print ' file not exist' return None with open(path_) as f : for line in f : s = line.split('<||>') if s[0] == '1' : self.maskSet[int(unicode(str(s[3].decode('utf-8')).replace('\n', '')))] = \ (int(unicode(str(s[0].decode('utf-8')).replace('\n', ''))), \ s[1].decode('utf-8'), \ int(unicode(str(s[2].decode('utf-8')).replace('\n', ''))), \ int(unicode(str(s[3].decode('utf-8')).replace('\n', '')))) #print self.maskSet[int(unicode(str(s[3].decode('utf-8')).replace('\n', '')))] os.remove(path_)