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
(self, param, failobj=None, header='content-type',
unquote=True)
| 709 | return params |
| 710 | |
| 711 | def get_param(self, param, failobj=None, header='content-type', |
| 712 | unquote=True): |
| 713 | """Return the parameter value if found in the Content-Type header. |
| 714 | |
| 715 | Optional failobj is the object to return if there is no Content-Type |
| 716 | header, or the Content-Type header has no such parameter. Optional |
| 717 | header is the header to search instead of Content-Type. |
| 718 | |
| 719 | Parameter keys are always compared case insensitively. The return |
| 720 | value can either be a string, or a 3-tuple if the parameter was RFC |
| 721 | 2231 encoded. When it's a 3-tuple, the elements of the value are of |
| 722 | the form (CHARSET, LANGUAGE, VALUE). Note that both CHARSET and |
| 723 | LANGUAGE can be None, in which case you should consider VALUE to be |
| 724 | encoded in the us-ascii charset. You can usually ignore LANGUAGE. |
| 725 | The parameter value (either the returned string, or the VALUE item in |
| 726 | the 3-tuple) is always unquoted, unless unquote is set to False. |
| 727 | |
| 728 | If your application doesn't care whether the parameter was RFC 2231 |
| 729 | encoded, it can turn the return value into a string as follows: |
| 730 | |
| 731 | rawparam = msg.get_param('foo') |
| 732 | param = email.utils.collapse_rfc2231_value(rawparam) |
| 733 | |
| 734 | """ |
| 735 | if header not in self: |
| 736 | return failobj |
| 737 | for k, v in self._get_params_preserve(failobj, header): |
| 738 | if k.lower() == param.lower(): |
| 739 | if unquote: |
| 740 | return _unquotevalue(v) |
| 741 | else: |
| 742 | return v |
| 743 | return failobj |
| 744 | |
| 745 | def set_param(self, param, value, header='Content-Type', requote=True, |
| 746 | charset=None, language='', replace=False): |