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


Python Message.getFromAddress方法代码示例

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


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

示例1: convert

# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import getFromAddress [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()
开发者ID:zacheryschiller,项目名称:amr,代码行数:67,代码来源:convertClintonMail.py


注:本文中的Message.Message.getFromAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。