mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Use os.path.dirname() for getting the directory name of a path (#81504)
This commit is contained in:
parent
1826795d37
commit
fa9a51e528
@ -54,11 +54,10 @@ def write_utf8_file(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
tmp_filename = ""
|
tmp_filename = ""
|
||||||
tmp_path = os.path.split(filename)[0]
|
|
||||||
try:
|
try:
|
||||||
# Modern versions of Python tempfile create this file with mode 0o600
|
# Modern versions of Python tempfile create this file with mode 0o600
|
||||||
with tempfile.NamedTemporaryFile(
|
with tempfile.NamedTemporaryFile(
|
||||||
mode="w", encoding="utf-8", dir=tmp_path, delete=False
|
mode="w", encoding="utf-8", dir=os.path.dirname(filename), delete=False
|
||||||
) as fdesc:
|
) as fdesc:
|
||||||
fdesc.write(utf8_data)
|
fdesc.write(utf8_data)
|
||||||
tmp_filename = fdesc.name
|
tmp_filename = fdesc.name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user