def loadFromXML(xmlRoot, namespace_main, namespace_common, version, poolOfMessages): if version == "0.1": id = str(xmlRoot.get("id")) name = xmlRoot.get("name") description = xmlRoot.get("description") session = Session(id, name, description) if xmlRoot.find("{" + namespace_common + "}messages-ref") is not None: xmlMessages = xmlRoot.find("{" + namespace_common + "}messages-ref") for xmlMessage in xmlMessages.findall("{" + namespace_common + "}message-ref"): id = xmlMessage.get("id") message = poolOfMessages.getMessageByID(id) if message is not None: message.setSession(session) session.addMessage(message) if xmlRoot.find("{" + namespace_common + "}applicativeData") is not None: xmlApplicativeData = xmlRoot.find("{" + namespace_common + "}applicativeData") for xmlData in xmlApplicativeData.findall("{" + namespace_common + "}data"): data = ApplicativeData.loadFromXML(xmlData, namespace_common, version) if data is not None: session.addApplicativeData(data) return session return None
def importFileChooserButton_file_set_cb(self, button): """importFileChooserButton_file_set_cb: Callback executed when the user has provided a new file""" # Retrieve the selected file toImport = self.view.getSelectedFileToImport() if toImport is None: self.logger.debug("No file selected, impossible to import it") return self.logger.debug("File to import: {0}".format(toImport)) try: self.parsedApplicativeData = ApplicativeData.loadFromCSV(toImport) self.view.displayStatusMessage(_("{0} applicative data have been found.".format(len(self.parsedApplicativeData)))) self.view.activateApply() except ApplicativeDataException, e: self.logger.warning("An error prevented to parse and extract the applicative data from provided file {0} : {1}".format(toImport, e)) self.view.displayErrorMessage(_("Error : {0}".format(e))) self.view.deactivateApply()
def importFileChooserButton_file_set_cb(self, button): """importFileChooserButton_file_set_cb: Callback executed when the user has provided a new file""" # Retrieve the selected file toImport = self.view.getSelectedFileToImport() if toImport is None: self.logger.debug("No file selected, impossible to import it") return self.logger.debug("File to import: {0}".format(toImport)) try: self.parsedApplicativeData = ApplicativeData.loadFromCSV(toImport) self.view.displayStatusMessage( _("{0} applicative data have been found.".format(len(self.parsedApplicativeData))) ) self.view.activateApply() except ApplicativeDataException, e: self.logger.warning( "An error prevented to parse and extract the applicative data from provided file {0} : {1}".format( toImport, e ) ) self.view.displayErrorMessage(_("Error : {0}".format(e))) self.view.deactivateApply()