当前位置: 首页>>代码示例>>Python>>正文


Python HelperFunctions.wrapOnEmptyElementSplit方法代码示例

本文整理汇总了Python中HelperFunctions.wrapOnEmptyElementSplit方法的典型用法代码示例。如果您正苦于以下问题:Python HelperFunctions.wrapOnEmptyElementSplit方法的具体用法?Python HelperFunctions.wrapOnEmptyElementSplit怎么用?Python HelperFunctions.wrapOnEmptyElementSplit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HelperFunctions的用法示例。


在下文中一共展示了HelperFunctions.wrapOnEmptyElementSplit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fix

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import wrapOnEmptyElementSplit [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.wrapOnEmptyElementSplit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。