Back to index

python3.2  3.2.2
Classes | Functions | Variables
email.message Namespace Reference


class  Message


def _unquotevalue


list __all__ = ['Message']
 Charset = _charset.Charset
string SEMISPACE = '; '
tuple tspecials
tuple end = s.find(';', end + 1)
list f = s[:end]
tuple i = f.index('=')
list s = s[end:]

Function Documentation

def email.message._unquotevalue (   value) [private]

Definition at line 112 of file

00113 def _unquotevalue(value):
00114     # This is different than utils.collapse_rfc2231_value() because it doesn't
00115     # try to convert the value to a unicode.  Message.get_param() and
00116     # Message.get_params() are both currently defined to return the tuple in
00117     # the face of RFC 2231 parameters.
00118     if isinstance(value, tuple):
00119         return value[0], value[1], utils.unquote(value[2])
00120     else:
00121         return utils.unquote(value)

Here is the caller graph for this function:

Variable Documentation

Definition at line 7 of file

email.message.Charset = _charset.Charset

Definition at line 21 of file

tuple email.message.end = s.find(';', end + 1)

Definition at line 100 of file

list email.message.f = s[:end]

Definition at line 103 of file

tuple email.message.i = f.index('=')

Definition at line 105 of file

list email.message.s = s[end:]

Definition at line 108 of file

Definition at line 23 of file

Initial value:
00001 re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')# How to figure out if we are processing strings that come from a byte# source with undecodable characters._has_surrogates = re.compile(    '([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)').search# Helper functionsdef _sanitize_header(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 valuedef _splitparam(param):    # Split header parameters.  BAW: this may be too simple.  It isn't    # strictly RFC 2045 (section 5.1) compliant, but it catches most headers    # found in the wild.  We may eventually need a full fledged parser.    # RDM: we might have a Header here; for now just stringify it.    a, sep, b = str(param).partition(';')    if not sep:        return a.strip(), None    return a.strip(), b.strip()def _formatparam(param, value=None, quote=True):    """Convenience function to format and return a key=value pair.
00003     This will quote the value if needed or if quote is true.  If value is a
00004     three tuple (charset, language, value), it will be encoded according
00005     to RFC2231 rules.  If it contains non-ascii characters it will likewise
00006     be encoded according to RFC2231 rules, using the utf-8 charset and
00007     a null language.
00008     """    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            return '%s="%s"' % (param, utils.quote(value))        else:            return '%s=%s' % (param, value)    else:        return paramdef _parseparam(s):    # RDM This might be a Header, so for now stringify it.    s = ';' + str(s)    plist = []    while s[:1] == ';':        s = s[1:]        end = s.find(';')        while end > 0 and (s.count('"', 0, end)

Definition at line 27 of file