Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/ansys/dpf/core/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from __future__ import annotations

import os
from pathlib import Path
from pathlib import Path, PurePosixPath, PureWindowsPath
import traceback
from typing import TYPE_CHECKING, Union
import warnings
Expand Down Expand Up @@ -159,7 +159,9 @@
['...tmp...file.rst']

"""
filepath = Path(filepath)
filepath = (
PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath)
)
extension = filepath.suffix
# Handle .res files from CFX
if key == "" and extension == ".res":
Expand Down Expand Up @@ -290,7 +292,7 @@
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file1.rst', key='rst', domain_id=1)

"""
path = Path(path)
path = PurePosixPath(path) if self._server.os == "posix" else PureWindowsPath(path)

Check warning on line 295 in src/ansys/dpf/core/data_sources.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/data_sources.py#L295

Added line #L295 was not covered by tests
if key:
self._api.data_sources_set_domain_result_file_path_with_key_utf8(
self, str(path), key, domain_id
Expand Down Expand Up @@ -341,7 +343,9 @@
# The filename needs to be a fully qualified file name
# if not os.path.dirname(filepath)

filepath = Path(filepath)
filepath = (
PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath)
)
if not filepath.parent.name:
# append local path
filepath = Path.cwd() / filepath.name
Expand Down Expand Up @@ -391,7 +395,9 @@

"""
# The filename needs to be a fully qualified file name
filepath = Path(filepath)
filepath = (

Check warning on line 398 in src/ansys/dpf/core/data_sources.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/data_sources.py#L398

Added line #L398 was not covered by tests
PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath)
)
if not filepath.parent.name:
# append local path
filepath = Path.cwd() / filepath.name
Expand Down Expand Up @@ -424,7 +430,9 @@
The default is ``""``, in which case the key is found directly.
"""
# The filename needs to be a fully qualified file name
filepath = Path(filepath)
filepath = (

Check warning on line 433 in src/ansys/dpf/core/data_sources.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/data_sources.py#L433

Added line #L433 was not covered by tests
PurePosixPath(filepath) if self._server.os == "posix" else PureWindowsPath(filepath)
)
if not filepath.parent.name:
# append local path
filepath = Path.cwd() / filepath.name
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ def streams_provider(self):
return self._stream_provider

def _set_data_sources(self, var_inp):
from pathlib import Path
from pathlib import PurePath

if isinstance(var_inp, dpf.core.DataSources):
self._data_sources = var_inp
elif isinstance(var_inp, (str, Path)):
elif isinstance(var_inp, (str, PurePath)):
self._data_sources = DataSources(var_inp, server=self._server)
else:
self._data_sources = DataSources(server=self._server)
Expand Down