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


Python header.Header方法代码示例

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


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

示例1: _sanitize_header

# 需要导入模块: from future.backports.email import header [as 别名]
# 或者: from future.backports.email.header import Header [as 别名]
def _sanitize_header(self, name, value):
        # If the header value contains surrogates, return a Header using
        # the unknown-8bit charset to encode the bytes as encoded words.
        if not isinstance(value, str):
            # Assume it is already a header object
            return value
        if _has_surrogates(value):
            return header.Header(value, charset=_charset.UNKNOWN8BIT,
                                 header_name=name)
        else:
            return value 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:13,代码来源:_policybase.py

示例2: header_fetch_parse

# 需要导入模块: from future.backports.email import header [as 别名]
# 或者: from future.backports.email.header import Header [as 别名]
def header_fetch_parse(self, name, value):
        """+
        If the value contains binary data, it is converted into a Header object
        using the unknown-8bit charset.  Otherwise it is returned unmodified.
        """
        return self._sanitize_header(name, value) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:8,代码来源:_policybase.py

示例3: fold

# 需要导入模块: from future.backports.email import header [as 别名]
# 或者: from future.backports.email.header import Header [as 别名]
def fold(self, name, value):
        """+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  Non-ASCII binary data are CTE encoded using the
        unknown-8bit charset.

        """
        return self._fold(name, value, sanitize=True) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:11,代码来源:_policybase.py

示例4: fold_binary

# 需要导入模块: from future.backports.email import header [as 别名]
# 或者: from future.backports.email.header import Header [as 别名]
def fold_binary(self, name, value):
        """+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  If cte_type is 7bit, non-ascii binary data is CTE
        encoded using the unknown-8bit charset.  Otherwise the original source
        header is used, with its existing line breaks and/or binary data.

        """
        folded = self._fold(name, value, sanitize=self.cte_type=='7bit')
        return folded.encode('ascii', 'surrogateescape') 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:13,代码来源:_policybase.py

示例5: _fold

# 需要导入模块: from future.backports.email import header [as 别名]
# 或者: from future.backports.email.header import Header [as 别名]
def _fold(self, name, value, sanitize):
        parts = []
        parts.append('%s: ' % name)
        if isinstance(value, str):
            if _has_surrogates(value):
                if sanitize:
                    h = header.Header(value,
                                      charset=_charset.UNKNOWN8BIT,
                                      header_name=name)
                else:
                    # If we have raw 8bit data in a byte string, we have no idea
                    # what the encoding is.  There is no safe way to split this
                    # string.  If it's ascii-subset, then we could do a normal
                    # ascii split, but if it's multibyte then we could break the
                    # string.  There's no way to know so the least harm seems to
                    # be to not split the string and risk it being too long.
                    parts.append(value)
                    h = None
            else:
                h = header.Header(value, header_name=name)
        else:
            # Assume it is a Header-like object.
            h = value
        if h is not None:
            parts.append(h.encode(linesep=self.linesep,
                                  maxlinelen=self.max_line_length))
        parts.append(self.linesep)
        return ''.join(parts) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:_policybase.py


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