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

Method __deserialize_file

kubernetes/aio/client/api_client.py:593–615  ·  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

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