|
8 | 8 | """ |
9 | 9 |
|
10 | 10 | import argparse |
11 | | - |
12 | 11 | try: |
13 | 12 | import importlib.metadata as importlib_metadata |
14 | 13 | except ImportError: |
@@ -117,6 +116,7 @@ def show_in_file_manager( |
117 | 116 | path_or_uri: Optional[Union[str, Sequence[str]]] = None, |
118 | 117 | open_not_select_directory: Optional[bool] = True, |
119 | 118 | file_manager: Optional[str] = None, |
| 119 | + allow_conversion: bool = True, |
120 | 120 | verbose: bool = False, |
121 | 121 | debug: bool = False, |
122 | 122 | ) -> None: |
@@ -163,6 +163,9 @@ def show_in_file_manager( |
163 | 163 | selecting it and displaying it in its parent directory. |
164 | 164 | :param file_manager: executable name to use. If not specified, then |
165 | 165 | valid_file_manager() will determine which file manager to use. |
| 166 | + :param allow_conversion: allow this function to automatically convert paths |
| 167 | + and URIs to the format needed by the file manager that will be called. Set |
| 168 | + to False if passing non-standard URIs. Ignored when running under WSL. |
166 | 169 | :param verbose: if True print command to be executed before launching |
167 | 170 | it |
168 | 171 | :param debug: if True print debugging information to stderr |
@@ -243,15 +246,21 @@ def show_in_file_manager( |
243 | 246 | uri = Path(wsl_details.linux_path).resolve().as_uri() |
244 | 247 | else: |
245 | 248 | if tools.is_uri(pu): |
246 | | - if tools.filemanager_requires_path(file_manager=file_manager): |
| 249 | + if ( |
| 250 | + tools.filemanager_requires_path(file_manager=file_manager) |
| 251 | + and allow_conversion |
| 252 | + ): |
247 | 253 | # Convert URI to regular path |
248 | 254 | uri = None |
249 | 255 | path = Path(path or tools.file_uri_to_path(pu)) |
250 | 256 | else: |
251 | 257 | uri = pu |
252 | 258 | path = None |
253 | 259 | else: |
254 | | - if tools.filemanager_requires_path(file_manager=file_manager): |
| 260 | + if ( |
| 261 | + tools.filemanager_requires_path(file_manager=file_manager) |
| 262 | + or not allow_conversion |
| 263 | + ): |
255 | 264 | path = Path(pu) |
256 | 265 | uri = None |
257 | 266 | else: |
|
0 commit comments