MCPcopy Index your code
hub / github.com/kubernetes-client/python / __deserialize_file

Method __deserialize_file

kubernetes/client/api_client.py:587–609  ·  view source on GitHub ↗

Deserializes body to file Saves response body into a file in a temporary folder, using the filename from the `Content-Disposition` header if provided. :param response: RESTResponse. :return: file path.

(self, response)

Source from the content-addressed store, hash-verified

585 )
586
587 def __deserialize_file(self, response):
588 """Deserializes body to file
589
590 Saves response body into a file in a temporary folder,
591 using the filename from the `Content-Disposition` header if provided.
592
593 :param response: RESTResponse.
594 :return: file path.
595 """
596 fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
597 os.close(fd)
598 os.remove(path)
599
600 content_disposition = response.getheader("Content-Disposition")
601 if content_disposition:
602 filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
603 content_disposition).group(1)
604 path = os.path.join(os.path.dirname(path), filename)
605
606 with open(path, "wb") as f:
607 f.write(response.data)
608
609 return path
610
611 def __deserialize_primitive(self, data, klass):
612 """Deserializes string to primitive type.

Callers 1

deserializeMethod · 0.95

Calls 5

writeMethod · 0.80
closeMethod · 0.45
getheaderMethod · 0.45
groupMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected