本文整理匯總了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)
#.........這裏部分代碼省略.........