From 204ea77ed37ec8bedee7465577106a3ac420523f Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sat, 27 Oct 2018 21:01:52 +0000 Subject: [PATCH] Don't LBYL when creating missing data directories It's better to ask forgiveness than permission. Just try to create parent directories for any data file, and don't error if they already exist. --- mudpy/data.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mudpy/data.py b/mudpy/data.py index 25b423b..b73959a 100644 --- a/mudpy/data.py +++ b/mudpy/data.py @@ -111,10 +111,9 @@ class Data: ): # make parent directories if necessary - if not os.path.exists(os.path.dirname(self.source)): - old_umask = os.umask(normal_umask) - os.makedirs(os.path.dirname(self.source)) - os.umask(old_umask) + old_umask = os.umask(normal_umask) + os.makedirs(os.path.dirname(self.source), exist_ok=True) + os.umask(old_umask) # backup the file if "mudpy.limit" in self.universe.contents: -- 2.11.0