コード例 #1
0
	def checkFormat(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		if(srcExcel == None):
			self.printError("[%s] not exist!!" % (srcFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		if(srcData == None):
			self.printError("[%s] not exist!!" % (self.mRule.mSrcTitle))
			return -1

		baseString = self.handerString(self.mRule.mRule)

		cnt = 1
		accept = True
		for data in srcData:
			cnt = cnt + 1
			data = str(data)
			if(len(data) < 1):
				continue

			formatString = self.handerString(data)
			if(formatString != baseString):
				self.printError('format error row: %d\n' % (cnt))
				self.printError('[%s]  [%s]  [%s]\n' % (self.mRule.mSrcName, self.mRule.mSrcSheet, self.mRule.mSrcTitle))
				self.printError('base:\n%s\n' % (self.mRule.mRule))
				self.printError('error:\n%s\n\n' % (data))
				accept = False

		if(accept == False):
			return -1
		return 0
コード例 #2
0
	def checkRelate(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)
		descFullPath = os.path.join(self.mDirPath, self.mRule.mDescName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		descExcel = ExcelMgr.loadExcel(descFullPath)
		if(srcExcel == None or descExcel == None):
			self.printError("[%s] or [%s] not exist!!" % (srcFullPath, descFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		descData = ExcelMgr.getExcelRowData(descFullPath, self.mRule.mDescSheet, self.mRule.mDescTitle)
		if(srcData == None or descData == None):
			self.printError("[%s] or [%s] not exist!!" % (self.mRule.mSrcTitle, self.mRule.mDescTitle))
			return -1

		cnt = 1
		accept = True
		checkList = self.formatCheckList(self.mRule.mRule)
		for src in srcData:
			cnt = cnt + 1
			src = str(src)
			if(len(src) < 1):
				continue

			formatList = self.formatString(src)
			for idx in checkList:
				exist = False
				if(idx >= len(formatList)):
					break
				val = formatList[idx]
				for desc in descData:
					if(int(val) == int(desc)):
						exist = True
				if(exist == False):
					self.printError('relate error row: %d\nrelate error value: %s\n' % (cnt, val))
					self.printError('[%s]  [%s]  [%s]\n' % (self.mRule.mSrcName, self.mRule.mSrcSheet, self.mRule.mSrcTitle))
					self.printError('[%s]  [%s]  [%s]\n\n' % (self.mRule.mDescName, self.mRule.mDescSheet, self.mRule.mDescTitle))
					accept = False

		if(accept == False):
			return -1
		return 0
コード例 #3
0
	def newCheckRelate(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)
		descFullPath = os.path.join(self.mDirPath, self.mRule.mDescName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		descExcel = ExcelMgr.loadExcel(descFullPath)
		if(srcExcel == None or descExcel == None):
			self.printError("[%s] or [%s] not exist!!" % (srcFullPath, descFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		self.descData = ExcelMgr.getExcelRowData(descFullPath, self.mRule.mDescSheet, self.mRule.mDescTitle)
		if(srcData == None or self.descData == None):
			self.printError("[%s] or [%s] not exist!!" % (self.mRule.mSrcTitle, self.mRule.mDescTitle))
			return -1

		self.cnt = 1
		self.accept = True

		baseString = self.cvtNumber2Symbol(self.mRule.mRule)
		self.relateList = self.buildRelate(baseString)
		baseString = self.removeSymbol(baseString, '(')
		baseString = self.removeSymbol(baseString, ')')

		for src in srcData:
			self.cnt = self.cnt + 1
			src = str(src)
			if(len(src) < 1):
				continue
			self.buildRelateValue(src)
			desString = self.cvtNumber2Symbol(src)
			# print baseString
			# print desString
			self.matchString1(baseString, 0, desString, 0)

		if(self.accept == False):
		 	return -1
		return 0
コード例 #4
0
	def checkRange(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		if(srcExcel == None):
			self.printError("[%s] not exist!!" % (srcFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		if(srcData == None):
			self.printError("[%s] not exist!!" % (self.mRule.mSrcTitle))
			return -1

		baseList = self.formatString(self.mRule.mRule)
		rangeList = self.formatCheckList(self.mRule.mRule)
		rangeValList = []
		for idx in rangeList:
			base = baseList[idx]
			rangeVal = base[(base.find('(') + 1):(base.find(')'))]
			valList = re.split('[-]', rangeVal)
			rangeValList.append(int(valList[0]))
			rangeValList.append(int(valList[1]))

		cnt = 1
		accept = True
		checkList = self.formatCheckList(self.mRule.mRule)
		for src in srcData:
			cnt = cnt + 1
			src = str(src)
			if(len(src) < 1):
				continue
				
			cntt = 0
			formatList = self.formatString(src)
			for idx in checkList:
				exist = False
				if(idx >= len(formatList)):
					break
				val = formatList[idx]
				tmp = cntt * 2
				if(int(val) < rangeValList[tmp] or rangeValList[tmp + 1] < int(val)):
					self.printError('range error row: %d\n %d not in range %d-%d\n' % (cnt, int(val), rangeValList[tmp], rangeValList[tmp + 1]))
					self.printError('[%s]  [%s]  [%s]\n' % (self.mRule.mSrcName, self.mRule.mSrcSheet, self.mRule.mSrcTitle))
					accept = False
				cntt = cntt + 1

		if(accept == False):
			return -1
		return 0
コード例 #5
0
	def checkMultFormat(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		if(srcExcel == None):
			self.printError("[%s] not exist!!" % (srcFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		if(srcData == None):
			self.printError("[%s] not exist!!" % (self.mRule.mSrcTitle))
			return -1

		begin = 0
		length = len(self.mRule.mRule)
		baseStringList = []
		while(begin < length):
			bPos = self.mRule.mRule.find('(', begin, length) + 1
			ePos = self.mRule.mRule.find(')', begin, length)
			if(bPos == -1 or ePos == -1):
				break
			sub = self.mRule.mRule[bPos: ePos]
			baseString = self.handerString1(sub)
			baseStringList.append(baseString)
			begin = ePos + 1

		cnt = 1
		accept = True
		for data in srcData:
			cnt = cnt + 1
			data = str(data)
			multformat = False
			formatString = self.handerString1(data)
			for baseString in baseStringList:
				if(formatString == baseString):
					multformat = True
					break

			if(multformat == False):
				self.printError('format error row: %d\n' % (cnt))
				self.printError('[%s]  [%s]  [%s]\n' % (self.mRule.mSrcName, self.mRule.mSrcSheet, self.mRule.mSrcTitle))
				self.printError('base:\n%s\n' % (self.mRule.mRule))
				self.printError('error:\n%s\n\n' % (data))
				accept = False

		if(accept == False):
			return -1
		return 0
コード例 #6
0
	def newCheckFormat(self):
		srcFullPath = os.path.join(self.mDirPath, self.mRule.mSrcName)

		srcExcel = ExcelMgr.loadExcel(srcFullPath)
		if(srcExcel == None):
			self.printError("[%s] not exist!!" % (srcFullPath))
			return -1

		srcData = ExcelMgr.getExcelRowData(srcFullPath, self.mRule.mSrcSheet, self.mRule.mSrcTitle)
		if(srcData == None):
			self.printError("[%s] not exist!!" % (self.mRule.mSrcTitle))
			return -1

		# baseString = self.handerString(self.mRule.mRule)
		baseString = self.mRule.mRule
		if(self.checkFormat1(baseString)):
			baseString = self.cvtNumber2Symbol(baseString)
			print baseString
			cnt = 1
			accept = True
			for data in srcData:
				cnt = cnt + 1
				data = str(data)
				if(len(data) < 1):
					continue

				desString = self.cvtNumber2Symbol(data)
				# print desString
				if not (self.matchString(baseString, 0, desString, 0)):
					self.printError('format error row: %d\n' % (cnt))
					self.printError('[%s]  [%s]  [%s]\n' % (self.mRule.mSrcName, self.mRule.mSrcSheet, self.mRule.mSrcTitle))
					self.printError('base:\n%s\n' % (self.mRule.mRule))
					self.printError('error:\n%s\n\n' % (data))
					accept = False

			if(accept == False):
				return -1
		return 0