I have a dict with a series of bools
to specify if a particular aspect of my program will be run (e.g. settings['A']
and settings['B']
).
If they are run the results need to go into an aptly named directory. The directory names (not the entire path) are also stored in the dict (e.g. settings['outputDirNameOut1']
and settings['outputDirNameA']
)
In order to create the directories I'm using the following code.
for each in filePathList:
path = os.path.dirname(each)
if not os.path.exists(os.path.join(path, settings['outputDirNameOut1'])):
os.makedirs(os.path.join(path, settings['outputDirNameOut1']))
if settings['A'] is True and not os.path.exists(os.path.join(path, settings['outputDirNameA'])):
os.makedirs(os.path.join(path, settings['outputDirNameA']))
if settings['B'] is True and not os.path.exists(os.path.join(path, settings['outputDirNameB'])):
os.makedirs(os.path.join(path, settings['outputDirNameThreshold']))
if settings['C'] is True and not os.path.exists(os.path.join(path, settings['outputDirNameC'])):
os.makedirs(os.path.join(path, settings['outputDirNameC']))
os.makedirs(os.path.join(path, settings['outputDirNameOut2']))
if settings['D'] is True and not os.path.exists(os.path.join(path, settings['outputDirNameOut2'])):
os.makedirs(os.path.join(path, settings['outputDirNameOut2']))
I'm wondering if there's a simpler, easier to read way to accomplish this.