From 51b43772327bc8ac632f31ff6c6103d91e79227b Mon Sep 17 00:00:00 2001 From: Yuriy Novostavskiy Date: Fri, 5 Apr 2024 17:00:52 +0000 Subject: [PATCH] reformatted with black Signed-off-by: Yuriy Novostavskiy --- .gitignore | 1 + oras/provider.py | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 0569f39..2eb46af 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ oras.egg-info/ .env env __pycache__ +.python-version diff --git a/oras/provider.py b/oras/provider.py index 1416fd7..17e93f9 100644 --- a/oras/provider.py +++ b/oras/provider.py @@ -226,7 +226,7 @@ def upload_blob( container: container_type, layer: dict, do_chunked: bool = False, - refresh_headers: bool = True + refresh_headers: bool = True, ) -> requests.Response: """ Prepare and upload a blob. @@ -253,9 +253,13 @@ def upload_blob( # This is currently disabled unless the user asks for it, as # it doesn't seem to work for all registries if not do_chunked: - response = self.put_upload(blob, container, layer, refresh_headers=refresh_headers) + response = self.put_upload( + blob, container, layer, refresh_headers=refresh_headers + ) else: - response = self.chunked_upload(blob, container, layer, refresh_headers=refresh_headers) + response = self.chunked_upload( + blob, container, layer, refresh_headers=refresh_headers + ) # If we have an empty layer digest and the registry didn't accept, just return dummy successful response if ( @@ -477,7 +481,11 @@ def download_blob( return outfile def put_upload( - self, blob: str, container: oras.container.Container, layer: dict, refresh_headers: bool = True + self, + blob: str, + container: oras.container.Container, + layer: dict, + refresh_headers: bool = True, ) -> requests.Response: """ Upload to a registry via put. @@ -550,7 +558,11 @@ def _get_location( return session_url def chunked_upload( - self, blob: str, container: oras.container.Container, layer: dict, refresh_headers: bool = True + self, + blob: str, + container: oras.container.Container, + layer: dict, + refresh_headers: bool = True, ) -> requests.Response: """ Upload via a chunked upload. @@ -632,7 +644,10 @@ def _parse_response_errors(self, response: requests.Response): pass def upload_manifest( - self, manifest: dict, container: oras.container.Container, refresh_headers: bool = True + self, + manifest: dict, + container: oras.container.Container, + refresh_headers: bool = True, ) -> requests.Response: """ Read a manifest file and upload it. @@ -746,7 +761,9 @@ def push(self, *args, **kwargs) -> requests.Response: logger.debug(f"Preparing layer {layer}") # Upload the blob layer - response = self.upload_blob(blob, container, layer, refresh_headers=refresh_headers) + response = self.upload_blob( + blob, container, layer, refresh_headers=refresh_headers + ) self._check_200_response(response) # Do we need to cleanup a temporary targz? @@ -788,13 +805,17 @@ def push(self, *args, **kwargs) -> requests.Response: if config_file is None else nullcontext(config_file) ) as config_file: - response = self.upload_blob(config_file, container, conf, refresh_headers=refresh_headers) + response = self.upload_blob( + config_file, container, conf, refresh_headers=refresh_headers + ) self._check_200_response(response) # Final upload of the manifest manifest["config"] = conf - self._check_200_response(self.upload_manifest(manifest, container, refresh_headers=refresh_headers)) + self._check_200_response( + self.upload_manifest(manifest, container, refresh_headers=refresh_headers) + ) print(f"Successfully pushed {container}") return response