88from enum import Enum
99from io import IOBase
1010from os import makedirs , path
11- from typing import Any , Iterable , List , Optional , Set , Tuple , MutableMapping
11+ from typing import Any , Callable , Iterable , List , Optional , Set , Tuple , MutableMapping
1212
1313from wcmatch .glob import GLOBSTAR , globmatch
1414
@@ -176,14 +176,18 @@ def upload(
176176 """
177177 ...
178178
179- def _get_file_transfer_paths (self , file : RemoteFile , local_directory : str ) -> MutableMapping [str , Any ]:
179+ def _get_file_transfer_paths (self , file : RemoteFile , local_directory : str , parse_file_path_from_uri : Optional [ Callable ] = None ) -> MutableMapping [str , Any ]:
180180 preserve_directory_structure = self .preserve_directory_structure ()
181- file_uri = file .uri
182- file_name = path .basename (file_uri )
183- file_folder = path .dirname (file_uri )
181+ if not parse_file_path_from_uri :
182+ file_path = file .uri
183+ else :
184+ file_path = parse_file_path_from_uri (file .uri )
185+
186+ file_name = path .basename (file_path )
187+ file_folder = path .dirname (file_path )
184188 if preserve_directory_structure :
185189 # Remove left slashes from source path format to make relative path for writing locally
186- file_relative_path = file_uri .lstrip ("/" )
190+ file_relative_path = file_path .lstrip ("/" )
187191 else :
188192 file_relative_path = file_name
189193 local_file_path = path .join (local_directory , file_relative_path )
@@ -195,7 +199,7 @@ def _get_file_transfer_paths(self, file: RemoteFile, local_directory: str) -> Mu
195199 self .LOCAL_FILE_PATH : local_file_path ,
196200 self .FILE_NAME : file_name ,
197201 self .FILE_FOLDER : file_folder ,
198- self .SOURCE_FILE_URI : file_uri ,
202+ self .SOURCE_FILE_URI : file . uri ,
199203
200204 }
201205 return file_paths
0 commit comments