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


Python BytesIO.create_date方法代码示例

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


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

示例1: parse_postmark

# 需要导入模块: from django.utils.six import BytesIO [as 别名]
# 或者: from django.utils.six.BytesIO import create_date [as 别名]
    def parse_postmark(self, obj):
        from_field = (obj["FromFull"]["Name"], obj["FromFull"]["Email"])
        tos = [(o["Name"], o["Email"]) for o in obj["ToFull"]]
        ccs = [(o["Name"], o["Email"]) for o in obj["CcFull"]]
        attachments = []
        for a in obj["Attachments"]:
            attachment = BytesIO(base64.b64decode(a["Content"]))
            attachment.content_type = a["ContentType"]
            attachment.size = a["ContentLength"]
            attachment.name = a["Name"]
            attachment.create_date = None
            attachment.mod_date = None
            attachment.read_date = None
            attachments.append(attachment)

        return {
            "msgobj": obj,
            "date": self.parse_date(obj["Date"]),
            "subject": obj["Subject"],
            "body": obj["TextBody"],
            "html": obj["HtmlBody"],
            "from": from_field,
            "to": tos,
            "cc": ccs,
            "resent_to": [],
            "resent_cc": [],
            "attachments": attachments,
        }
开发者ID:gabelula,项目名称:froide,代码行数:30,代码来源:email_utils.py

示例2: parse_attachment

# 需要导入模块: from django.utils.six import BytesIO [as 别名]
# 或者: from django.utils.six.BytesIO import create_date [as 别名]
    def parse_attachment(self, message_part):
        content_disposition = message_part.get("Content-Disposition", None)
        if content_disposition:
            dispo_type, dispo_dict = self.parse_dispositions(content_disposition)
            if dispo_type == "attachment" or (dispo_type == 'inline' and
                    'filename' in dispo_dict):
                content_type = message_part.get("Content-Type", None)
                file_data = message_part.get_payload(decode=True)
                if file_data is None:
                    payloads = message_part.get_payload()
                    file_data = '\n\n'.join([p.as_string() for p in payloads])
                    try:
                        file_data = file_data.encode('utf-8')
                    except:
                        pass

                attachment = BytesIO(file_data)
                attachment.content_type = message_part.get_content_type()
                attachment.size = len(file_data)
                attachment.name = None
                attachment.create_date = None
                attachment.mod_date = None
                attachment.read_date = None
                if "filename" in dispo_dict:
                    attachment.name = dispo_dict['filename']
                if content_type:
                    _, content_dict = self.parse_dispositions(content_type)
                    if 'name' in content_dict:
                        attachment.name = content_dict['name']
                if attachment.name is None and content_type == 'message/rfc822':
                    p = Parser()
                    msgobj = p.parse(BytesIO(attachment.getvalue()))
                    subject = self.parse_header_field(msgobj['Subject'])
                    if subject:
                        attachment.name = '%s.eml' % subject[:45]
                if "create-date" in dispo_dict:
                    attachment.create_date = dispo_dict['create-date']  # TODO: datetime
                if "modification-date" in dispo_dict:
                    attachment.mod_date = dispo_dict['modification-date']  # TODO: datetime
                if "read-date" in dispo_dict:
                    attachment.read_date = dispo_dict['read-date']  # TODO: datetime
                return attachment
        return None
开发者ID:Bastiantorres,项目名称:votainteligente-portal-electoral,代码行数:45,代码来源:froide_email_utils.py

示例3: parse_attachment

# 需要导入模块: from django.utils.six import BytesIO [as 别名]
# 或者: from django.utils.six.BytesIO import create_date [as 别名]
 def parse_attachment(self, message_part):
     content_disposition = message_part.get("Content-Disposition", None)
     if content_disposition:
         dispo_type, dispo_dict = self.parse_dispositions(content_disposition)
         if dispo_type == "attachment" or (dispo_type == "inline" and "filename" in dispo_dict):
             content_type = message_part.get("Content-Type", None)
             file_data = message_part.get_payload(decode=True)
             if file_data is None:
                 payloads = message_part.get_payload()
                 file_data = "\n\n".join([p.as_string() for p in payloads]).encode("utf-8")
             attachment = BytesIO(file_data)
             attachment.content_type = message_part.get_content_type()
             attachment.size = len(file_data)
             attachment.name = None
             attachment.create_date = None
             attachment.mod_date = None
             attachment.read_date = None
             if "filename" in dispo_dict:
                 attachment.name = dispo_dict["filename"]
             if content_type:
                 _, content_dict = self.parse_dispositions(content_type)
                 if "name" in content_dict:
                     attachment.name = content_dict["name"]
             if attachment.name is None and content_type == "message/rfc822":
                 p = Parser()
                 msgobj = p.parse(BytesIO(attachment.getvalue()))
                 subject = self.parse_header_field(msgobj["Subject"])
                 if subject:
                     attachment.name = "%s.eml" % subject[:45]
             if "create-date" in dispo_dict:
                 attachment.create_date = dispo_dict["create-date"]  # TODO: datetime
             if "modification-date" in dispo_dict:
                 attachment.mod_date = dispo_dict["modification-date"]  # TODO: datetime
             if "read-date" in dispo_dict:
                 attachment.read_date = dispo_dict["read-date"]  # TODO: datetime
             return attachment
     return None
开发者ID:gabelula,项目名称:froide,代码行数:39,代码来源:email_utils.py


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