本文整理汇总了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)
#.........这里部分代码省略.........