♻️ Directory creation to use os.makedirs with exist_ok (#435)

Simplified code and improved readability / Ensured functionality remains the same by allowing directory to exist without error
This commit is contained in:
jackmappotion 2024-06-18 08:41:02 +09:00 committed by GitHub
parent 23f6a1e4c7
commit 7a0727757f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,8 +52,7 @@ def read_file(input_path):
def download_url(input_path):
output_dir = "cache"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok=True)
base_name = os.path.basename(input_path)
output_path = os.path.join(output_dir, base_name)
img_data = requests.get(input_path).content