Lines Matching refs:value
25 # existence of which force quoting of the parameter value.
39 def _formatparam(param, value=None, quote=True):
40 """Convenience function to format and return a key=value pair.
42 This will quote the value if needed or if quote is true. If value is a
43 three tuple (charset, language, value), it will be encoded according
48 if value is not None and len(value) > 0:
50 # are (charset, language, value). charset is a string, not a Charset
52 if isinstance(value, tuple):
55 value = utils.encode_rfc2231(value[2], value[0], value[1])
56 return '%s=%s' % (param, value)
59 value.encode('ascii')
62 value = utils.encode_rfc2231(value, 'utf-8', '')
63 return '%s=%s' % (param, value)
66 if quote or tspecials.search(value):
67 return '%s="%s"' % (param, utils.quote(value))
69 return '%s=%s' % (param, value)
93 def _unquotevalue(value):
95 # try to convert the value to a unicode. Message.get_param() and
98 if isinstance(value, tuple):
99 return value[0], value[1], utils.unquote(value[2])
101 return utils.unquote(value)
255 decoded if this header's value is `quoted-printable' or `base64'. If
316 value, defects = decode_b(b''.join(bpayload.splitlines()))
319 return value
331 """Set the payload to the given value.
410 """Get a header value.
421 """Set the value of a header.
454 for field, value in self._headers:
490 """Get a header value.
506 def set_raw(self, name, value):
507 """Store name and value in the model without modification.
511 self._headers.append((name, value))
514 """Return the (name, value) header pairs without modification.
547 to dashes. Normally the parameter will be added as key="value" unless
548 value is None, in which case only the key will be added. If a
549 parameter value contains non-ASCII characters it can be specified as a
550 three-tuple of (charset, language, value), in which case it will be
598 type this will always return a value.
605 value = self.get('content-type', missing)
606 if value is missing:
609 ctype = _splitparam(value)[0].lower()
655 value = self.get(header, missing)
656 if value is missing:
659 for p in _parseparam(value):
675 The elements of the returned list are 2-tuples of key/value pairs, as
677 while the right hand side is the value. If there is no `=' sign in
678 the parameter the value is the empty string. The value is as
683 Content-Type. If unquote is True, the value is unquoted.
696 """Return the parameter value if found in the Content-Type header.
703 value can either be a string, or a 3-tuple if the parameter was RFC
704 2231 encoded. When it's a 3-tuple, the elements of the value are of
708 The parameter value (either the returned string, or the VALUE item in
712 encoded, it can turn the return value into a string as follows:
728 def set_param(self, param, value, header='Content-Type', requote=True,
732 If the parameter already exists in the header, its value will be
733 replaced with the new value.
737 value will be appended as per RFC 2045.
746 if not isinstance(value, tuple) and charset:
747 value = (charset, language, value)
755 ctype = _formatparam(param, value, requote)
758 [ctype, _formatparam(param, value, requote)])
765 append_param = _formatparam(param, value, requote)
783 value. All values will be quoted as necessary unless requote is
891 # Replace the existing Content-Type header with the new value
945 Each item will either be a string (the value of the charset parameter
946 in the Content-Type header of that part) or the value of the
962 value = self.get('content-disposition')
963 if value is None:
965 c_d = _splitparam(value)[0].lower()
986 base Message class, but defaults to None, meaning that the policy value
1139 for name, value in self._headers:
1141 part_headers.append((name, value))
1143 keep_headers.append((name, value))