def _parseIndividualFieldDetail(self, value, fieldAttr, outDataEntry): if not value.strip(' '): return value = value.strip(' ') fieldDetail = value pointerFileNo = None if fieldAttr.isSetType(): setDict = fieldAttr.getSetMembers() if setDict and value in setDict: fieldDetail = setDict[value] elif fieldAttr.isFilePointerType() or fieldAttr.isVariablePointerType(): fileNo = None ien = None if fieldAttr.isFilePointerType(): filePointedTo = fieldAttr.getPointedToFile() if filePointedTo: fileNo = filePointedTo.getFileNo() ien = value else: fieldDetail = 'No Pointed to File' else: # for variable pointer type vpInfo = value.split(';') if len(vpInfo) != 2: logging.error("Unknown variable pointer format: %s" % value) fieldDetail = "Unknow Variable Pointer" else: fileNo = self.getFileNoByGlobalLocation(vpInfo[1]) ien = vpInfo[0] if not fileNo: logging.warn("Could not find File for %s" % value) fieldDetail = 'Global Root: %s, IEN: %s' % (vpInfo[1], ien) if fileNo and ien: fieldDetail = '^'.join((fileNo, ien)) idxName = self._getFileKeyIndex(fileNo, ien) if idxName: idxes = str(idxName).split('^') if len(idxes) == 1: fieldDetail = '^'.join((fieldDetail, str(idxName))) elif len(idxes) == 3: fieldDetail = '^'.join((fieldDetail, str(idxes[-1]))) elif fileNo == self._curFileNo: pointerFileNo = fileNo else: logging.warn("Can not find value for %s, %s" % (ien, fileNo)) elif fieldAttr.getType() == FileManField.FIELD_TYPE_DATE_TIME: # datetime if value.find(',') >=0: fieldDetail = horologToDateTime(value) else: outDt = fmDtToPyDt(value) if outDt: fieldDetail = outDt else: logging.warn("Could not parse Date/Time: %s" % value) elif fieldAttr.getName().upper().startswith("TIMESTAMP"): # timestamp field if value.find(',') >=0: fieldDetail = horologToDateTime(value) if outDataEntry: dataField = FileManDataField(fieldAttr.getFieldNo(), fieldAttr.getType(), fieldAttr.getName(), fieldDetail) if pointerFileNo: self._addDataFieldToPointerRef(pointerFileNo, value, dataField) outDataEntry.addField(dataField) if fieldAttr.getFieldNo() == '.01': outDataEntry.name = fieldDetail outDataEntry.type = fieldAttr.getType() return fieldDetail
def _parseIndividualFieldDetail(self, value, fieldAttr, outDataEntry): if not value.strip(' '): return value = value.strip(' ') fieldDetail = value pointerFileNo = None if fieldAttr.isSetType(): setDict = fieldAttr.getSetMembers() if setDict and value in setDict: fieldDetail = setDict[value] elif fieldAttr.isFilePointerType() or fieldAttr.isVariablePointerType( ): fileNo = None ien = None if fieldAttr.isFilePointerType(): filePointedTo = fieldAttr.getPointedToFile() if filePointedTo: fileNo = filePointedTo.getFileNo() ien = value else: fieldDetail = 'No Pointed to File' else: # for variable pointer type vpInfo = value.split(';') if len(vpInfo) != 2: logging.error("Unknown variable pointer format: %s" % value) fieldDetail = "Unknow Variable Pointer" else: fileNo = self.getFileNoByGlobalLocation(vpInfo[1]) ien = vpInfo[0] if not fileNo: logging.warn("Could not find File for %s" % value) fieldDetail = 'Global Root: %s, IEN: %s' % (vpInfo[1], ien) if fileNo and ien: fieldDetail = '^'.join((fileNo, ien)) idxName = self._getFileKeyIndex(fileNo, ien) if idxName: idxes = str(idxName).split('^') if len(idxes) == 1: fieldDetail = '^'.join((fieldDetail, str(idxName))) elif len(idxes) == 3: fieldDetail = '^'.join((fieldDetail, str(idxes[-1]))) elif fileNo == self._curFileNo: pointerFileNo = fileNo else: logging.warn("Can not find value for %s, %s" % (ien, fileNo)) elif fieldAttr.getType( ) == FileManField.FIELD_TYPE_DATE_TIME: # datetime if value.find(',') >= 0: fieldDetail = horologToDateTime(value) else: outDt = fmDtToPyDt(value) if outDt: fieldDetail = outDt else: logging.warn("Could not parse Date/Time: %s" % value) elif fieldAttr.getName().upper().startswith( "TIMESTAMP"): # timestamp field if value.find(',') >= 0: fieldDetail = horologToDateTime(value) if outDataEntry: dataField = FileManDataField(fieldAttr.getFieldNo(), fieldAttr.getType(), fieldAttr.getName(), fieldDetail) if pointerFileNo: self._addDataFieldToPointerRef(pointerFileNo, value, dataField) outDataEntry.addField(dataField) if fieldAttr.getFieldNo() == '.01': outDataEntry.name = fieldDetail outDataEntry.type = fieldAttr.getType() return fieldDetail