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

Method del_param

Lib/email/message.py:796–816  ·  view source on GitHub ↗

Remove the given parameter completely from the Content-Type header. The header will be re-written in place without the parameter or its value. All values will be quoted as necessary unless requote is False. Optional header specifies an alternative to the Content-Type

(self, param, header='content-type', requote=True)

Source from the content-addressed store, hash-verified

794 self[header] = ctype
795
796 def del_param(self, param, header='content-type', requote=True):
797 """Remove the given parameter completely from the Content-Type header.
798
799 The header will be re-written in place without the parameter or its
800 value. All values will be quoted as necessary unless requote is
801 False. Optional header specifies an alternative to the Content-Type
802 header.
803 """
804 if header not in self:
805 return
806 new_ctype = ''
807 for p, v in self.get_params(header=header, unquote=requote):
808 if p.lower() != param.lower():
809 if not new_ctype:
810 new_ctype = _formatparam(p, v, requote)
811 else:
812 new_ctype = SEMISPACE.join([new_ctype,
813 _formatparam(p, v, requote)])
814 if new_ctype != self.get(header):
815 del self[header]
816 self[header] = new_ctype
817
818 def set_type(self, type, header='Content-Type', requote=True):
819 """Set the main type and subtype for the Content-Type header.

Calls 5

get_paramsMethod · 0.95
getMethod · 0.95
_formatparamFunction · 0.70
lowerMethod · 0.45
joinMethod · 0.45