make_file_pathname¶
- pyrcs.utils.make_file_pathname(cls_instance, data_name, ext='.pkl', data_dir=None)[source]¶
Generates a file pathname for saving data in a specified format.
- Parameters:
cls_instance (object) – An instance of a class managing a specific data cluster.
data_name (str) – The key identifying the data within a specific code cluster.
ext (str) – The file extension for the saved data; defaults to
".pkl"
.data_dir (str | None) – The directory where the file will be saved; defaults to
None
.
- Returns:
The pathname for saving the data file.
- Return type:
str
Examples:
>>> from pyrcs.utils import make_file_pathname >>> from pyrcs.line_data import Bridges >>> import os >>> bridges = Bridges() >>> example_pathname = make_file_pathname(bridges, data_name="example-data", ext=".pkl") >>> os.path.relpath(example_pathname) 'pyrcs\data\line-data\bridges\example-data.pkl'