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

Method get_filename

Lib/email/message.py:850–864  ·  view source on GitHub ↗

Return the filename associated with the payload if present. The filename is extracted from the Content-Disposition header's 'filename' parameter, and it is unquoted. If that header is missing the 'filename' parameter, this method falls back to looking for the 'name'

(self, failobj=None)

Source from the content-addressed store, hash-verified

848 self.set_param(p, v, header, requote)
849
850 def get_filename(self, failobj=None):
851 """Return the filename associated with the payload if present.
852
853 The filename is extracted from the Content-Disposition header's
854 'filename' parameter, and it is unquoted. If that header is missing
855 the 'filename' parameter, this method falls back to looking for the
856 'name' parameter.
857 """
858 missing = object()
859 filename = self.get_param('filename', missing, 'content-disposition')
860 if filename is missing:
861 filename = self.get_param('name', missing, 'content-type')
862 if filename is missing:
863 return failobj
864 return utils.collapse_rfc2231_value(filename).strip()
865
866 def get_boundary(self, failobj=None):
867 """Return the boundary associated with the payload if present.

Callers 2

_dispatchMethod · 0.45

Calls 2

get_paramMethod · 0.95
stripMethod · 0.45

Tested by 1