Skip to content

Commit faf4806

Browse files
committed
doc: modified another src file
1 parent d2c940f commit faf4806

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ansys/dpf/core/plugins.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"""
2929

3030
import os.path
31+
from pathlib import Path
3132

3233
try:
3334
import importlib.metadata as importlib_metadata
@@ -60,14 +61,14 @@ def load_plugin_on_server(plugin, server=None, symbol="load_operators", generate
6061
# Get the path to the plugin from the package installation
6162
if len([p for p in importlib_metadata.files(plugin) if "__init__.py" in str(p)]) > 0:
6263
file_path = [p for p in importlib_metadata.files(plugin) if "__init__.py" in str(p)][0]
63-
plugin_path = str(os.path.dirname(file_path.locate()))
64+
plugin_path = str(file_path.locate().parent)
6465
# For some reason the "locate()" function returns a path with src doubled
65-
plugin_path = plugin_path.replace("src" + os.path.sep + "src", "src")
66+
plugin_path = Path(plugin_path.replace("src" + os.path.sep + "src", "src"))
6667
elif len([p for p in importlib_metadata.files(plugin) if ".pth" in str(p)]) > 0:
6768
path_file = [p for p in importlib_metadata.files(plugin) if ".pth" in str(p)][0].locate()
68-
with open(path_file, "r") as file:
69-
plugin_path = file.readline()[:-1]
70-
plugin_path = os.path.join(plugin_path, "ansys", "dpf", "plugins", plugin_name)
69+
with path_file.open("r") as file:
70+
plugin_path = Path(file.readline()[:-1])
71+
plugin_path = plugin_path / "ansys" / "dpf" / "plugins" / plugin_name
7172
else:
7273
raise ModuleNotFoundError(f"Could not locate files for plugin {plugin}")
7374

@@ -93,7 +94,7 @@ def load_plugin_on_server(plugin, server=None, symbol="load_operators", generate
9394
# Upload xml file for the plugin
9495
_ = dpf.upload_files_in_folder(
9596
target_xml_path,
96-
os.path.join(plugin_path, os.pardir),
97+
plugin_path.parent,
9798
specific_extension=".xml",
9899
server=server,
99100
)

0 commit comments

Comments
 (0)