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


Python utils.collapse_rfc2231_value方法代码示例

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


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

示例1: _unquotevalue

# 需要导入模块: from future.backports.email import utils [as 别名]
# 或者: from future.backports.email.utils import collapse_rfc2231_value [as 别名]
def _unquotevalue(value):
    # This is different than utils.collapse_rfc2231_value() because it doesn't
    # try to convert the value to a unicode.  Message.get_param() and
    # Message.get_params() are both currently defined to return the tuple in
    # the face of RFC 2231 parameters.
    if isinstance(value, tuple):
        return value[0], value[1], utils.unquote(value[2])
    else:
        return utils.unquote(value) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:11,代码来源:message.py

示例2: get_param

# 需要导入模块: from future.backports.email import utils [as 别名]
# 或者: from future.backports.email.utils import collapse_rfc2231_value [as 别名]
def get_param(self, param, failobj=None, header='content-type',
                  unquote=True):
        """Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            param = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        """
        if header not in self:
            return failobj
        for k, v in self._get_params_preserve(failobj, header):
            if k.lower() == param.lower():
                if unquote:
                    return _unquotevalue(v)
                else:
                    return v
        return failobj 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:35,代码来源:message.py

示例3: get_filename

# 需要导入模块: from future.backports.email import utils [as 别名]
# 或者: from future.backports.email.utils import collapse_rfc2231_value [as 别名]
def get_filename(self, failobj=None):
        """Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        """
        missing = object()
        filename = self.get_param('filename', missing, 'content-disposition')
        if filename is missing:
            filename = self.get_param('name', missing, 'content-type')
        if filename is missing:
            return failobj
        return utils.collapse_rfc2231_value(filename).strip() 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:17,代码来源:message.py

示例4: get_boundary

# 需要导入模块: from future.backports.email import utils [as 别名]
# 或者: from future.backports.email.utils import collapse_rfc2231_value [as 别名]
def get_boundary(self, failobj=None):
        """Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        """
        missing = object()
        boundary = self.get_param('boundary', missing)
        if boundary is missing:
            return failobj
        # RFC 2046 says that boundaries may begin but not end in w/s
        return utils.collapse_rfc2231_value(boundary).rstrip() 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:14,代码来源:message.py


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