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


Python utils.quote方法代码示例

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


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

示例1: _formatparam

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def _formatparam(param, value=None, quote=True):
    """Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.
    """
    if value is not None and len(value) > 0:
        # A tuple is used for RFC 2231 encoded parameter values where items
        # are (charset, language, value).  charset is a string, not a Charset
        # instance.
        if isinstance(value, tuple):
            # Encode as per RFC 2231
            param += '*'
            value = utils.encode_rfc2231(value[2], value[0], value[1])
        # BAW: Please check this.  I think that if quote is set it should
        # force quoting even if not necessary.
        if quote or tspecials.search(value):
            return '%s="%s"' % (param, utils.quote(value))
        else:
            return '%s=%s' % (param, value)
    else:
        return param 
开发者ID:glmcdona,项目名称:meddle,代码行数:25,代码来源:message.py

示例2: _formatparam

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def _formatparam(param, value=None, quote=True):
    """Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    """
    if value is not None and len(value) > 0:
        # A tuple is used for RFC 2231 encoded parameter values where items
        # are (charset, language, value).  charset is a string, not a Charset
        # instance.
        if isinstance(value, tuple):
            # Encode as per RFC 2231
            param += '*'
            value = utils.encode_rfc2231(value[2], value[0], value[1])
        # BAW: Please check this.  I think that if quote is set it should
        # force quoting even if not necessary.
        if quote or tspecials.search(value):
            return '%s="%s"' % (param, utils.quote(value))
        else:
            return '%s=%s' % (param, value)
    else:
        return param 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:message.py

示例3: node_format

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def node_format( self, v ):
		fmt = []
		if v in self.lV:
			fmt.append( 'label="{}"'.format( quote( str( self.lV[ v ] ) ) ) )
		if v in self.hV:
			fmt.append( 'color={}'.format( self.hV[ v ] ) )
		elif v not in self.V:
			fmt.append( 'style=invis' )
		if fmt:
			return '[{}]'.format( ', '.join( fmt ) )
		return '' 
开发者ID:mapio,项目名称:GraphvizAnim,代码行数:13,代码来源:animation.py

示例4: edge_format

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def edge_format( self, e ):
		fmt = []
		if e in self.lE:
			fmt.append('label="{}"'.format( quote( str( self.lE[ e ] ) ) ) )
		if e in self.hE:
			fmt.append('color={}'.format( self.hE[ e ] ) )
		elif e not in self.E:
			fmt.append('style=invis')
		if fmt:
			return '[{}]'.format( ', '.join( fmt ) )
		return '' 
开发者ID:mapio,项目名称:GraphvizAnim,代码行数:13,代码来源:animation.py

示例5: graphs

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def graphs( self ):
		steps = self.steps()
		V, E = set(), set()
		for step in steps:
			V |= step.V
			E |= step.E
		graphs = []
		for n, s in enumerate( steps ):
			graph = [ 'digraph G {' ]
			for v in V: graph.append( '"{}" {};'.format( quote( str( v ) ), s.node_format( v ) ) )
			for e in E: graph.append( '"{}" -> "{}" {};'.format( quote( str( e[ 0 ] ) ), quote( str( e[ 1 ] ) ), s.edge_format( e ) ) )
			graph.append( '}' )
			graphs.append( '\n'.join( graph ) )
		
		return graphs 
开发者ID:mapio,项目名称:GraphvizAnim,代码行数:17,代码来源:animation.py

示例6: _formatparam

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def _formatparam(param, value=None, quote=True):
    """Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    """
    if value is not None and len(value) > 0:
        # A tuple is used for RFC 2231 encoded parameter values where items
        # are (charset, language, value).  charset is a string, not a Charset
        # instance.  RFC 2231 encoded values are never quoted, per RFC.
        if isinstance(value, tuple):
            # Encode as per RFC 2231
            param += '*'
            value = utils.encode_rfc2231(value[2], value[0], value[1])
            return '%s=%s' % (param, value)
        else:
            try:
                value.encode('ascii')
            except UnicodeEncodeError:
                param += '*'
                value = utils.encode_rfc2231(value, 'utf-8', '')
                return '%s=%s' % (param, value)
        # BAW: Please check this.  I think that if quote is set it should
        # force quoting even if not necessary.
        if quote or tspecials.search(value):
            return '%s="%s"' % (param, utils.quote(value))
        else:
            return '%s=%s' % (param, value)
    else:
        return param 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:35,代码来源:message.py

示例7: content_disposition

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import quote [as 别名]
def content_disposition(disposition, filename):
    """
    Generates a content disposition hedaer given a
    *disposition* and a *filename*. The filename needs
    to be the base name of the path, i.e. instead of
    ``~/file.txt`` you need to pass in ``file.txt``.
    The filename is automatically quoted.
    """
    yield 'Content-Disposition'
    yield '%s; filename="%s"' % (disposition, quote(filename)) 
开发者ID:eugene-eeo,项目名称:mailthon,代码行数:12,代码来源:headers.py


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