當前位置: 首頁>>代碼示例>>Python>>正文


Python HelperFunctions.extractTagContents方法代碼示例

本文整理匯總了Python中HelperFunctions.extractTagContents方法的典型用法代碼示例。如果您正苦於以下問題:Python HelperFunctions.extractTagContents方法的具體用法?Python HelperFunctions.extractTagContents怎麽用?Python HelperFunctions.extractTagContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HelperFunctions的用法示例。


在下文中一共展示了HelperFunctions.extractTagContents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _fix

# 需要導入模塊: import HelperFunctions [as 別名]
# 或者: from HelperFunctions import extractTagContents [as 別名]
	def _fix(self, row):
		new_row = row
		if row["Type"] == 'Letter':
			
			#print(row["Letter"])
			text = self._merged_pages(row['Pages'])
			if row:

				try:
					extracted_opener = HF.extractTagContents(text, 'opener')
					#print(extracted_opener[0])
					extracted_address = HF.extractTagContents(extracted_opener[0], 'address')
					#print('----')
					##print(extracted_address[0])
					try:
						wrapped = HF.wrapOnEmptyElementSplit(extracted_address[0],'lb','addrLine')
						#print(wrapped)
						#print('------')
						text = text.replace(extracted_address[0], wrapped)

						#print(text)
					except IndexError:
						#print('No address')
						pass

					extracted_closer = HF.extractTagContents(text, 'closer')
					#print(extracted_opener[0])
					extracted_address = HF.extractTagContents(extracted_closer[0], 'address')
					#print('----')
					##print(extracted_address[0])
					try:
						wrapped = HF.wrapOnEmptyElementSplit(extracted_address[0],'lb','addrLine')
						#print(wrapped)
						#print('------')
						text = text.replace(extracted_address[0], wrapped)

						#print(text)
					except IndexError:
						pass
						#print('No address')
				except Exception:
					pass
					#print('nameError')

				#print('-----')

				try:
					extracted_opener = HF.extractTagContents(text, 'opener')
					#print(extracted_opener[0])
					#print('-----')
					dateline_wrapped = WU.wrap_element_with_tags(extracted_opener[0], 'date', 'dateline')
					#print(dateline_wrapped)
					#print('-----')
					text = text.replace(extracted_opener[0], dateline_wrapped)
					#print(text)
				except:
					pass
					#print('DATEERROR')

				try:
					extracted_opener = HF.extractTagContents(text, 'opener')
					#print(extracted_opener)
					lb_stripped = extracted_opener[0].replace("<lb/>","")
					#print(lb_stripped)
					text = text.replace(extracted_opener[0], lb_stripped)
					#print(text)
				except:
					pass
					#print('DATEERROR')
			#print(text)
			split = self._split_pages(text)
			new_row["Pages"] = self._build_new_page_row(row['Pages'], split)
		


			addrPageID = [k for k, p in row["Pages"].items() if p["PageType"] == 'EnvelopeType']
			if addrPageID:
				text = row["Pages"][addrPageID[0]]["Translation"]
				#print(text)
				try:
					extracted_address = HF.extractTagContents(text, 'address')

					try:
						wrapped = HF.wrapOnEmptyElementSplit(extracted_address[0],'lb','addrLine')
						#print(wrapped)
						#print('------')
						text = text.replace(extracted_address[0], wrapped)
					except:
						pass
				except:
					pass
				#print(text)
				new_row["Pages"][addrPageID[0]]["Translation"] = text


		elif row["Type"] == 'PostcardAM':
			addrPageID = [k for k, p in row["Pages"].items() if p["PageType"] == 'AddressSide']
			
			text = row["Pages"][addrPageID[0]]["Translation"]
			#print(text)
#.........這裏部分代碼省略.........
開發者ID:oculardexterity,項目名稱:Letters-Processing,代碼行數:103,代碼來源:FixAddrLinesDates.py


注:本文中的HelperFunctions.extractTagContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。