From 2e12ab77a51ac9d28c00d52f9880784087c8cd89 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sun, 5 Nov 2023 10:42:09 +0100 Subject: [PATCH] simplify a tiny bit --- recipes.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/recipes.py b/recipes.py index 06f4629..92e02a3 100644 --- a/recipes.py +++ b/recipes.py @@ -1,5 +1,4 @@ from typing import Dict, List, Any, Optional -from dataclasses import dataclass import os import yaml @@ -10,6 +9,7 @@ class Unit: def __init__(self, name: str) -> None: self.name = name + class Units: def __init__(self) -> None: self.units: List[Unit] = [] @@ -251,15 +251,7 @@ def rendertemplate( print(f"rendering {file}") outstr = template.render(args) - try: - os.mkdir("out") - except FileExistsError: - pass - - try: - os.mkdir(f"out/{format}") - except FileExistsError: - pass + os.makedirs(f"out/{format}", exist_ok=True) with open(f"out/{format}/{file}", "w", encoding="utf-8") as f: f.write(outstr)