refactoring

This commit is contained in:
Devaev Maxim 2019-09-24 08:35:21 +03:00
parent d3d885e180
commit cfe0c07543

View File

@ -59,11 +59,11 @@ def _get_htpasswd_for_write(config: Section) -> Generator[passlib.apache.Htpassw
) )
try: try:
try: try:
stat = os.stat(path) st = os.stat(path)
with open(path, "rb") as htpasswd_file: with open(path, "rb") as htpasswd_file:
os.write(tmp_fd, htpasswd_file.read()) os.write(tmp_fd, htpasswd_file.read())
os.fchown(tmp_fd, stat.st_uid, stat.st_gid) os.fchown(tmp_fd, st.st_uid, st.st_gid)
os.fchmod(tmp_fd, stat.st_mode) os.fchmod(tmp_fd, st.st_mode)
finally: finally:
os.close(tmp_fd) os.close(tmp_fd)
htpasswd = passlib.apache.HtpasswdFile(tmp_path) htpasswd = passlib.apache.HtpasswdFile(tmp_path)