def generateInputJson(self): try: #Generate Index Configuration File csvgen= CSVgenerator(self.file,_start_word_1_,keyField_1,fieldList) csvFile=_input_directory_+"RoamingArea.csv" indexInfoList_1=csvgen.generateIndexDict(self.file, _start_word_1_, keyField_1) indexInfoList_2_a=csvgen.generateIndexDict(self.file, _start_word_2_, keyField_2_a_) indexInfoList_2_b=csvgen.generateIndexDict(self.file, _start_word_2_, keyField_2_b_) indexInfoList_2=indexInfoList_2_a+indexInfoList_2_b csvgen.addPrefixTokey(indexInfoList_2,'RAP') indexInfoList_3=csvgen.generateIndexDict(self.file, _start_word_3_, keyField_3) csvgen.addPrefixTokey(indexInfoList_3 , 'HGNSP') indexInfoList = indexInfoList_1+indexInfoList_2+indexInfoList_3 csvgen.writeDictToCSV(csvFile, indexInfoList) self.logger.info("csv updated---"+csvFile) indexdict=indexInfoList # End Dynamic Generation Code inputJson=self.parseAndGenerateInputMap(indexdict); filename =_input_directory_+"ericsson_"+_obj_name_+".json" with open(filename, 'w') as f1: json.dump(inputJson, f1, indent=4) self.logger.info("Json generated after parsing Input file ---"+str(inputJson)) except(FileNotFoundError): self.logger.error("Input file missing:-") logging.exception(FileNotFoundError) raise ApplicationError("Input file missing for object:- "+config.nokiaObjectName+" Add input files & retry") except(Exception): self.logger.error("Error while parsing input dump, check for the correct format") raise return filename
def generateInputJson(self): try: # Start Dynamic Generation code csvgen = CSVgenerator(self.file, _start_word_, keyField, fieldList) csvFile = _input_directory_ + "ODBPlan.csv" indexInfoList = csvgen.generateIndexDict(self.file, _start_word_, keyField) indexInfoList2 = csvgen.generateIndexDict(self.file, _start_word_, _object_start_) indexInfoList = indexInfoList2 + indexInfoList csvgen.addPrefixTokey(indexInfoList, 'RAP') csvgen.writeDictToCSV(csvFile, indexInfoList) self.logger.info("csv updated---" + csvFile) indexdict = indexInfoList #End Dynamic Generation code inputJson = self.parseAndGenerateInputMap(indexdict) filename = _input_directory_ + "ericsson_" + _obj_name_ + ".json" with open(filename, 'w') as f1: json.dump(inputJson, f1, indent=4) self.logger.info("Json generated after parsing Input file ---" + str(inputJson)) except (FileNotFoundError): self.logger.error("Input file missing:-") logging.exception(FileNotFoundError) raise ApplicationError("Input file missing for object:- " + config.nokiaObjectName + " Add input files & retry") except (Exception): self.logger.error( "Error while parsing input dump, check for the correct format") raise return filename