Skip to content

Commit d86005e

Browse files
author
Rajesh Meena
committed
removes dependency on path type defined by user. Adopts based on server type
1 parent 2b9568a commit d86005e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from __future__ import annotations
2626

2727
import os
28-
from pathlib import Path, PurePath
28+
from pathlib import Path, PurePosixPath, PureWindowsPath
2929
import traceback
3030
from typing import TYPE_CHECKING, Union
3131
import warnings
@@ -159,7 +159,7 @@ def set_result_file_path(
159159
['...tmp...file.rst']
160160
161161
"""
162-
filepath = Path(filepath) if not isinstance(filepath, PurePath) else filepath
162+
filepath = PurePosixPath(filepath) if self._server.os=='posix' else PureWindowsPath(filepath)
163163
extension = filepath.suffix
164164
# Handle .res files from CFX
165165
if key == "" and extension == ".res":
@@ -290,7 +290,7 @@ def set_domain_result_file_path(
290290
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file1.rst', key='rst', domain_id=1)
291291
292292
"""
293-
path = Path(path) if not isinstance(path, PurePath) else path
293+
path = PurePosixPath(path) if self._server.os=='posix' else PureWindowsPath(path)
294294
if key:
295295
self._api.data_sources_set_domain_result_file_path_with_key_utf8(
296296
self, str(path), key, domain_id
@@ -341,7 +341,7 @@ def add_file_path(
341341
# The filename needs to be a fully qualified file name
342342
# if not os.path.dirname(filepath)
343343

344-
filepath = Path(filepath) if not isinstance(filepath, PurePath) else filepath
344+
filepath = PurePosixPath(filepath) if self._server.os=='posix' else PureWindowsPath(filepath)
345345
if not filepath.parent.name:
346346
# append local path
347347
filepath = Path.cwd() / filepath.name
@@ -391,7 +391,7 @@ def add_domain_file_path(
391391
392392
"""
393393
# The filename needs to be a fully qualified file name
394-
filepath = Path(filepath) if not isinstance(filepath, PurePath) else filepath
394+
filepath = PurePosixPath(filepath) if self._server.os=='posix' else PureWindowsPath(filepath)
395395
if not filepath.parent.name:
396396
# append local path
397397
filepath = Path.cwd() / filepath.name
@@ -424,7 +424,7 @@ def add_file_path_for_specified_result(
424424
The default is ``""``, in which case the key is found directly.
425425
"""
426426
# The filename needs to be a fully qualified file name
427-
filepath = Path(filepath) if not isinstance(filepath, PurePath) else filepath
427+
filepath = PurePosixPath(filepath) if self._server.os=='posix' else PureWindowsPath(filepath)
428428
if not filepath.parent.name:
429429
# append local path
430430
filepath = Path.cwd() / filepath.name

0 commit comments

Comments
 (0)