mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
circleci: Use the joy of os.makedirs(..., exist_ok=True).
Since Python 3.2, we no longer need to write this little wrapper all over our own code! There was much rejoicing.
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import errno
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
def generate_dockerfile_directories(dockerfile_path: str) -> None:
|
||||
if not os.path.exists(os.path.dirname(dockerfile_path)):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(dockerfile_path))
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
||||
|
||||
@@ -30,6 +21,6 @@ if __name__ == "__main__":
|
||||
|
||||
dockerfile_content = docker_template.format_map(dockerfile_settings[distro])
|
||||
dockerfile_path = "images/{}/Dockerfile".format(distro)
|
||||
generate_dockerfile_directories(dockerfile_path)
|
||||
os.makedirs(os.path.dirname(dockerfile_path), exist_ok=True)
|
||||
with open(dockerfile_path, "w") as f:
|
||||
f.write(dockerfile_content)
|
||||
|
||||
Reference in New Issue
Block a user