Skip to content

capturegraph.procedures.nodes.filesystem.files #

File management procedures handle the creation of individual file references for storing specific data items. Files are the fundamental storage units where captured data, user input, and processed results are persisted.

File procedures work with directories to create organized data structures and support type-safe data storage operations.

NewFile #

Bases: Procedure[PFile]

Creates a new file within a directory for storing data.

Creates a file reference that can be used to save captured data, user input, or processed results. The file will be created when data is actually saved to it.

Attributes:

Name Type Description
parent Procedure[PDirectory]

The directory to create the file in

name str

The base name of the file (without extension)

Note

File extensions are automatically determined by the app based on the type of data being saved. Do not include extensions in the name.

Source code in capturegraph-lib/capturegraph/procedures/nodes/filesystem/files.py
@make_procedure
class NewFile(Procedure[PFile]):
    """
    Creates a new file within a directory for storing data.

    Creates a file reference that can be used to save captured data,
    user input, or processed results. The file will be created when
    data is actually saved to it.

    Attributes:
        parent (Procedure[PDirectory]): The directory to create the file in
        name (str): The base name of the file (without extension)

    Note:
        File extensions are automatically determined by the app based
        on the type of data being saved. Do not include extensions in the name.
    """

    parent: Procedure[PDirectory]
    name: str

    def __post_init__(self) -> None:
        super().__post_init__()

        # Ignore first character, which is always a dot for hidden files
        if "." in self.name[1:]:
            raise ValueError(
                "File name should not contain file extensions. "
                "File extensions are determined by the app when saving the file."
            )