make_file_pathname
- pyrcs.utils.make_file_pathname(cls, data_name, ext='.pkl', data_dir=None)[source]
Make a pathname for saving data as a file of a certain format.
- Parameters:
cls (object) – (An instance of) a class for a certain data cluster.
data_name (str) – The key to the dict-type data of a certain code cluster.
ext (str) – A file extension, defaults to
".pkl"
.data_dir (str | None) – The name of a folder where the data is saved, defaults to
None
.
- Returns:
A pathname for saving the data.
- Return type:
str
Example:
>>> 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'