本文整理汇总了Python中Message.Message.getToAddress方法的典型用法代码示例。如果您正苦于以下问题:Python Message.getToAddress方法的具体用法?Python Message.getToAddress怎么用?Python Message.getToAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.getToAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import getToAddress [as 别名]
def convert(fileLocation):
fin = open("/Users/zschiller/Desktop/hillary_text/" + fileLocation, 'r')
data = fin.read()
fin.close()
# Formatting for errors in conversion
data = data.replace(" From:", "\nFrom:")
data = data.replace(" Sent:", "\nSent:")
data = data.replace(" To:", "\nTo:")
data = data.replace(" Subject:", "\nSubject:")
data = data.replace(" Attachments:", "\nAttachments:")
data = data.replace("06/30/2015", "06/30/2015\n")
data = data.replace("07/31/2015", "07/31/2015\n")
data = data.replace("08/31/2015", "08/31/2015\n")
data = data.replace(" UNCLASSIFIED", "\nUNCLASSIFIED")
data = data.splitlines()
fout = open(("/Users/zschiller/Desktop/fixed/" + fileLocation), 'w')
fout.write("Content-Type: text/plain; charset=UTF-8\n")
for i in range(len(data)):
# Fix leading space
data[i] = data[i].lstrip()
if data[i].strip() == '':
pass
elif data[i][0:12] == "UNCLASSIFIED":
pass
elif data[i][0:7] == "RELEASE":
pass
elif data[i][0:5] == "file:":
pass
elif data[i][0:2] == "B5":
pass
elif data[i][0:2] == "B6":
pass
else:
fout.write(data[i] + '\n')
fout.close()
new = Message("/Users/zschiller/Desktop/fixed/" + fileLocation)
if new.getError():
fout2 = open(("/Users/zschiller/Desktop/errors/" + fileLocation), 'w')
else:
fout2 = open(
("/Users/zschiller/Desktop/fixedMessages/" + fileLocation), 'w')
if (new.getToAddress() != None):
fout2.write("----------------------------------------------------\n")
fout2.write("TO--------------------------------------------------\n")
fout2.write(new.getToAddress() + '\n')
if (new.getFromAddress() != None):
fout2.write("FROM------------------------------------------------\n")
fout2.write(new.getFromAddress() + '\n')
if (new.getDate() != None):
fout2.write("DATE------------------------------------------------\n")
fout2.write(new.getDate() + '\n')
if (new.getSubject() != None):
fout2.write("SUBJECT---------------------------------------------\n")
fout2.write(new.getSubject() + '\n')
if (new.getBody() != None):
fout2.write("BODY------------------------------------------------\n")
fout2.write(new.getBody() + '\n')
if (new.getTokens() != None):
fout2.write("TOKENS----------------------------------------------\n")
fout2.write(str(new.getTokens()) + '\n')
fout2.close()
return new.getError()