FileItem (autotransform.item.file)

The implementation for the FileItem.

class autotransform.item.file.FileItem(*, key: str, extra_data: Dict[str, Any] | None = None)

Bases: Item

An item representing a file that can be used by AutoTransform. Provides some utility methods for interacting with the file.

name

The name of the component.

Type:

ClassVar[ItemName]

get_content() str

Gets the content of the file.

Returns:

The file’s content.

Return type:

str

get_path() str

Gets the path of the file.

Returns:

The file’s path.

Return type:

str

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: ClassVar[ItemName] = 'file'
revert() None

Reverts all changes to the file.

write_content(content: str) None

Writes new content to the file.

Parameters:

content (str) – The new content for the File.