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