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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

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

model_fields: ClassVar[dict[str, FieldInfo]] = {'extra_data': FieldInfo(annotation=Union[Dict[str, Any], NoneType], required=False, default=None), 'key': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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.