Skip to content

gufo.thor.utils

Various utilities.

ensure_directory(path)

Check directory is exists and create, if necessary.

Parameters:

Name Type Description Default
path Path

Directory path.

required

write_file(path, content, backup_path=None)

Write data to file.

Overwrite file content only if changed. Create all nessessary directories.

Parameters:

Name Type Description Default
path Path

File path.

required
content Union[str, bytes]

File content.

required
backup_path Optional[Path]

Path to store a copy of file when overwritten.

None

Returns:

Name Type Description
True bool

if file was written.

False bool

if file wasn't changed.