Home Assistant Unofficial Reference 2024.12.1
homeassistant.util.file Namespace Reference

Classes

class  WriteError
 

Functions

None write_utf8_file (str filename, bytes|str utf8_data, bool private=False, str mode="w")
 
None write_utf8_file_atomic (str filename, bytes|str utf8_data, bool private=False, str mode="w")
 

Variables

 _LOGGER = logging.getLogger(__name__)
 

Detailed Description

File utility functions.

Function Documentation

◆ write_utf8_file()

None homeassistant.util.file.write_utf8_file ( str  filename,
bytes | str  utf8_data,
bool   private = False,
str   mode = "w" 
)
Write a file and rename it into place.

Writes all or nothing.

Definition at line 45 of file file.py.

◆ write_utf8_file_atomic()

None homeassistant.util.file.write_utf8_file_atomic ( str  filename,
bytes | str  utf8_data,
bool   private = False,
str   mode = "w" 
)
Write a file and rename it into place using atomicwrites.

Writes all or nothing.

This function uses fsync under the hood. It should
only be used to write mission critical files as
fsync can block for a few seconds or longer is the
disk is busy.

Using this function frequently will significantly
negatively impact performance.

Definition at line 20 of file file.py.

Variable Documentation

◆ _LOGGER

homeassistant.util.file._LOGGER = logging.getLogger(__name__)
private

Definition at line 13 of file file.py.