MCPcopy Index your code
hub / github.com/python/cpython / get_param

Method get_param

Lib/email/message.py:711–743  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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):

Callers 15

set_paramMethod · 0.95
get_filenameMethod · 0.95
get_boundaryMethod · 0.95
get_content_charsetMethod · 0.95
test_getset_charsetMethod · 0.95
test_set_paramMethod · 0.95
test_set_paramMethod · 0.95
_find_bodyMethod · 0.80
iter_attachmentsMethod · 0.80
_handle_textMethod · 0.80
get_text_contentFunction · 0.80

Calls 3

_get_params_preserveMethod · 0.95
_unquotevalueFunction · 0.85
lowerMethod · 0.45

Tested by 15

test_getset_charsetMethod · 0.76
test_set_paramMethod · 0.76
test_set_paramMethod · 0.76
test_bad_paramMethod · 0.64
test_get_paramMethod · 0.64
test_del_paramMethod · 0.64
test_add_headerMethod · 0.64
test_add_headerMethod · 0.64