Skip to content

Commit 060cbc5

Browse files
changes in the guess_result_key function
1 parent 80524d6 commit 060cbc5

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,37 @@ def set_result_file_path(
180180

181181
@staticmethod
182182
def guess_result_key(filepath: str) -> str:
183-
"""Guess result key for files without a file extension."""
183+
"""Guess result key for files without a file extension.
184+
185+
Parameters
186+
----------
187+
filepath
188+
Path to the file.
189+
190+
Returns
191+
-------
192+
str
193+
Extension key name
194+
195+
Examples
196+
--------
197+
Gives the result key for the result file of the given path
198+
199+
>>> from ansys.dpf import core as dpf
200+
>>> from ansys.dpf.core import examples
201+
>>>
202+
>>> # Create the DataSources object
203+
>>> my_data_sources = dpf.DataSources()
204+
>>> # Download the result files
205+
>>> path = examples.download_d3plot_beam()
206+
>>> # Define the path where the main result file can be found
207+
>>> my_data_sources.set_result_file_path(filepath=path[0])
208+
>>> # Define the extension key for the file in the given path
209+
>>> my_file_key = my_data_sources.guess_result_key(filepath=path[0])
210+
>>> print(my_file_key)
211+
d3plot
212+
213+
"""
184214
result_keys = ["d3plot", "binout"]
185215
base_name = os.path.basename(filepath)
186216
# Handle files without extension

0 commit comments

Comments
 (0)