class documentation

class RelativeDataPath(RootModel[str]): (source)

View In Hierarchy

A relative path that is validated, and can have a Thing assigned to it.

Use set_saving_thing or set_saving_thing_if_unset to set the Thing whose data directory will be used for the final save.

Use the abs_data_path property to get the final path for saving.

Class Method validate_relative_path Validate the relative path is relative and has no parent dir references.
Method join Join a path to the end of this path.
Method save_to_tempdir Use a temporary directory to save raher than an OFMThing.
Method set_saving_thing Set the Thing that is saving the data.
Method set_saving_thing_if_unset Set the Thing that is saving the data if it is not already set.
Property abs_data_path The absolute data directory to save to.
Property save_location_set Return True if the saving thing is set.
Instance Variable _saving_thing Undocumented
@model_validator(mode='before')
@classmethod
def validate_relative_path(cls, value: str) -> str: (source)

Validate the relative path is relative and has no parent dir references.

def join(self, sub_path: str) -> RelativeDataPath: (source)

Join a path to the end of this path.

Returns
RelativeDataPathA new RelativeDataPath object with the path appended.
def save_to_tempdir(self) -> TemporaryDirectory: (source)

Use a temporary directory to save raher than an OFMThing.

Returns
TemporaryDirectorythe TemporaryDirectory object.
def set_saving_thing(self, thing: OFMThing | TemporaryDirectory): (source)

Set the Thing that is saving the data.

The thing can also be a TemporaryDirectory object.

This will set the data directory.

def set_saving_thing_if_unset(self, thing: OFMThing): (source)

Set the Thing that is saving the data if it is not already set.

Use this in an action to set the Thing for paths set via the API.

@property
abs_data_path: str = (source)

The absolute data directory to save to.

@property
save_location_set: bool = (source)

Return True if the saving thing is set.

_saving_thing: OFMThing | TemporaryDirectory | None = (source)

Undocumented