Dont fail if rc file dir doesnt exist
This commit is contained in:
parent
a993a71857
commit
2fcd57410a
1 changed files with 3 additions and 1 deletions
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
def atomic_write(path: str, data: Union[str, bytes]) -> None:
|
||||
mode = 'w' + ('b' if isinstance(data, bytes) else '')
|
||||
fd, tpath = mkstemp(dir=os.path.dirname(path), text=isinstance(data, str))
|
||||
base = os.path.dirname(path)
|
||||
os.makedirs(base, exist_ok=True)
|
||||
fd, tpath = mkstemp(dir=base, text=isinstance(data, str))
|
||||
with open(fd, mode) as f:
|
||||
shutil.copystat(path, tpath)
|
||||
f.write(data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue