|
25 | 25 | from __future__ import annotations |
26 | 26 |
|
27 | 27 | import os |
28 | | -from pathlib import Path |
| 28 | +from pathlib import Path, PurePosixPath, PureWindowsPath |
29 | 29 | import traceback |
30 | 30 | from typing import TYPE_CHECKING, Union |
31 | 31 | import warnings |
@@ -159,7 +159,9 @@ def set_result_file_path( |
159 | 159 | ['...tmp...file.rst'] |
160 | 160 |
|
161 | 161 | """ |
162 | | - filepath = Path(filepath) |
| 162 | + filepath = ( |
| 163 | + PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath) |
| 164 | + ) |
163 | 165 | extension = filepath.suffix |
164 | 166 | # Handle .res files from CFX |
165 | 167 | if key == "" and extension == ".res": |
@@ -290,7 +292,7 @@ def set_domain_result_file_path( |
290 | 292 | >>> my_data_sources.set_domain_result_file_path(path='/tmp/file1.rst', key='rst', domain_id=1) |
291 | 293 |
|
292 | 294 | """ |
293 | | - path = Path(path) |
| 295 | + path = PurePosixPath(path) if self._server.os == "posix" else PureWindowsPath(path) |
294 | 296 | if key: |
295 | 297 | self._api.data_sources_set_domain_result_file_path_with_key_utf8( |
296 | 298 | self, str(path), key, domain_id |
@@ -341,7 +343,9 @@ def add_file_path( |
341 | 343 | # The filename needs to be a fully qualified file name |
342 | 344 | # if not os.path.dirname(filepath) |
343 | 345 |
|
344 | | - filepath = Path(filepath) |
| 346 | + filepath = ( |
| 347 | + PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath) |
| 348 | + ) |
345 | 349 | if not filepath.parent.name: |
346 | 350 | # append local path |
347 | 351 | filepath = Path.cwd() / filepath.name |
@@ -391,7 +395,9 @@ def add_domain_file_path( |
391 | 395 |
|
392 | 396 | """ |
393 | 397 | # The filename needs to be a fully qualified file name |
394 | | - filepath = Path(filepath) |
| 398 | + filepath = ( |
| 399 | + PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath) |
| 400 | + ) |
395 | 401 | if not filepath.parent.name: |
396 | 402 | # append local path |
397 | 403 | filepath = Path.cwd() / filepath.name |
@@ -424,7 +430,9 @@ def add_file_path_for_specified_result( |
424 | 430 | The default is ``""``, in which case the key is found directly. |
425 | 431 | """ |
426 | 432 | # The filename needs to be a fully qualified file name |
427 | | - filepath = Path(filepath) |
| 433 | + filepath = ( |
| 434 | + PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath) |
| 435 | + ) |
428 | 436 | if not filepath.parent.name: |
429 | 437 | # append local path |
430 | 438 | filepath = Path.cwd() / filepath.name |
|
0 commit comments